Documentation ¶
Index ¶
- Variables
- func HandleError(w http.ResponseWriter, r *http.Request, err error)
- func IsHTTPNotFound(err error) bool
- type HTTPError
- func HTTPConflict() *HTTPError
- func HTTPForbidden(description string) *HTTPError
- func HTTPMethodNotAllowed() *HTTPError
- func HTTPNotFound() *HTTPError
- func OAuth2AccessDenied(description string) *HTTPError
- func OAuth2InvalidClient(description string) *HTTPError
- func OAuth2InvalidGrant(description string) *HTTPError
- func OAuth2InvalidRequest(description string) *HTTPError
- func OAuth2InvalidScope(description string) *HTTPError
- func OAuth2ServerError(description string) *HTTPError
- func OAuth2UnauthorizedClient(description string) *HTTPError
- func OAuth2UnsupportedGrantType(description string) *HTTPError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRequest is raised for all handler errors. ErrRequest = errors.New("request error") )
Functions ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, r *http.Request, err error)
HandleError is the top level error handler that should be called from all path handlers on error.
func IsHTTPNotFound ¶
Types ¶
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError wraps ErrRequest with more contextual information that is used to propagate and create suitable responses.
func HTTPConflict ¶
func HTTPConflict() *HTTPError
func HTTPForbidden ¶
func HTTPMethodNotAllowed ¶
func HTTPMethodNotAllowed() *HTTPError
func HTTPNotFound ¶
func HTTPNotFound() *HTTPError
func OAuth2AccessDenied ¶
OAuth2AccessDenied tells the client the authentication failed e.g. username/password are wrong, or a token has expired and needs reauthentication.
func OAuth2InvalidClient ¶
func OAuth2InvalidGrant ¶
func OAuth2InvalidRequest ¶
OAuth2InvalidRequest indicates a client error.
func OAuth2InvalidScope ¶
OAuth2InvalidScope tells the client it doesn't have the necessary scope to access the resource.
func OAuth2ServerError ¶
OAuth2ServerError tells the client we are at fault, this should never be seen in production. If so then our testing needs to improve.
func (*HTTPError) WithValues ¶
WithValues augments the error with a set of K/V pairs. Values should not use the "error" key as that's implicitly defined by WithError and could collide.