Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, err error)
WriteErrorResponse writes a generic error response to w.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, response interface{}, responseError error)
WriteResponse serialises response as JSON and writes it to w. response must be a pointer to a struct with string fields named Status and Error. On error it writes 400 for BadRequestError and 500 for everything else.
Types ¶
type BadRequestError ¶
type BadRequestError struct{ Err error }
BadRequestError signals that the caller supplied invalid input. WriteResponse maps it to HTTP 400 rather than 500.
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
func (*BadRequestError) Unwrap ¶
func (e *BadRequestError) Unwrap() error
type ForbiddenError ¶ added in v1.22.0
type ForbiddenError struct{}
ForbiddenError signals that the caller supplied a token that is not allowed to use this route (for example a read-scoped token on a write route).
func (*ForbiddenError) Error ¶ added in v1.22.0
func (e *ForbiddenError) Error() string
type NotFoundError ¶
type NotFoundError struct{ Path string }
NotFoundError signals that the requested resource or route does not exist. WriteResponse maps it to HTTP 404.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type TooManyRequestsError ¶ added in v1.22.0
type TooManyRequestsError struct{}
TooManyRequestsError signals that the caller exceeded the API rate limit.
func (*TooManyRequestsError) Error ¶ added in v1.22.0
func (e *TooManyRequestsError) Error() string
type UnauthorizedError ¶ added in v1.22.0
type UnauthorizedError struct{}
UnauthorizedError signals that the caller did not supply a valid API token.
func (*UnauthorizedError) Error ¶ added in v1.22.0
func (e *UnauthorizedError) Error() string