Documentation
¶
Overview ¶
Package httpx holds the HTTP helpers the handlers share: the JSON and error writers and the query parsers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBodyTooLarge = errors.New("request body too large")
ErrBodyTooLarge is returned for a body over the handler's limit.
Functions ¶
func ReadJSON ¶
ReadJSON decodes a JSON request body into dst. An empty or malformed body is a 422 StatusError, an oversized one a 413.
func StatusCodeOf ¶
StatusCodeOf returns the status an error carries, when it carries one.
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, detail string)
WriteError writes the error body {"detail": ...} with the status.
Types ¶
type StatusError ¶
StatusError is an error that carries its HTTP status and, when it stands for a sentinel, unwraps to it.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Unwrap ¶
func (e *StatusError) Unwrap() error
Unwrap returns the sentinel the error stands for, when there is one.