Documentation
¶
Overview ¶
Package problem implements errors similar to the ones described by RFC 7807.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResponder ¶
NewResponder returns a function that can be used to reply to HTTP requests with errors. If the error is a Problem or has an HTTPStatus method returning an int, its status code is used (or 500 if no status code was specified). If the HTTPStatus method returns 0, no status code is written and the user must write one elsewhere. If the error value is nil, a 200 is returned.
Types ¶
type Problem ¶
type Problem struct { // A URI reference that identifies the problem type. Type string `json:"type,omitempty"` // A short, human-readable summary of the problem type. Title string `json:"title,omitempty"` // The HTTP status code generated by the origin server for this occurrence of // the problem. Status int `json:"status,omitempty"` // A human-readable explanation specific to this occurrence of the problem. Detail string `json:"detail,omitempty"` // A URI reference that identifies the specific occurrence of the problem. Instance string `json:"instance,omitempty"` }
Problem respresents an unrecoverable error that occured during processing of an API request. Problems are designed to be embedded in application or endpoint specific error types. Consumers must use the "type" string as the primary identifier for the problem type.
func Status ¶
Status returns a problem for the provided HTTP status code that conveys no additional information.
func (Problem) HTTPStatus ¶
HTTPStatus returns the HTTP status as set by the origin server before encoding the problem.