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 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
Click to show internal directories.
Click to hide internal directories.