Documentation ¶
Index ¶
- Variables
- func HandleError(w http.ResponseWriter, r *http.Request, err error)
- func IsHTTPNotFound(err error) bool
- type Error
- func HTTPConflict() *Error
- func HTTPForbidden(description string) *Error
- func HTTPMethodNotAllowed() *Error
- func HTTPNotFound() *Error
- func OAuth2AccessDenied(description string) *Error
- func OAuth2InvalidClient(description string) *Error
- func OAuth2InvalidGrant(description string) *Error
- func OAuth2InvalidRequest(description string) *Error
- func OAuth2InvalidScope(description string) *Error
- func OAuth2ServerError(description string) *Error
- func OAuth2UnauthorizedClient(description string) *Error
- func OAuth2UnsupportedGrantType(description string) *Error
- type OAuth2Error
- type OAuth2ErrorType
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 ¶
IsHTTPNotFound interrogates the error type.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error wraps ErrRequest with more contextual information that is used to propagate and create suitable responses.
func HTTPConflict ¶
func HTTPConflict() *Error
HTTPConflict is raised when a request conflicts with another resource.
func HTTPForbidden ¶
HTTPForbidden is raised when a user isn't permitted to do something by RBAC.
func HTTPMethodNotAllowed ¶
func HTTPMethodNotAllowed() *Error
HTTPMethodNotAllowed is raised when the method is not supported.
func HTTPNotFound ¶
func HTTPNotFound() *Error
HTTPNotFound is raised when the requested resource doesn't exist.
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 ¶
OAuth2InvalidClient is raised when the client ID is not known.
func OAuth2InvalidGrant ¶
OAuth2InvalidGrant is raised when the requested grant is unknown.
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 OAuth2UnauthorizedClient ¶
OAuth2UnauthorizedClient indicates the client is not authorized to perform the requested operation.
func OAuth2UnsupportedGrantType ¶
OAuth2UnsupportedGrantType is raised when the requested grant is not supported.
func (*Error) 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.
type OAuth2Error ¶
type OAuth2Error struct { // Error defines the error type. Error OAuth2ErrorType `json:"error"` // Description is a verbose description of the error. This should be // informative to the end user, not a bunch of debugging nonsense. We // keep that in telemetry dats. //nolint:tagliatelle Description string `json:"error_description"` }
OAuth2Error is the type sent on the wire on error.
type OAuth2ErrorType ¶
type OAuth2ErrorType string
OAuth2ErrorType defines our core error type based on oauth2.
const ( AccessDenied OAuth2ErrorType = "access_denied" Conflict OAuth2ErrorType = "conflict" Forbidden OAuth2ErrorType = "forbidden" InvalidClient OAuth2ErrorType = "invalid_client" InvalidGrant OAuth2ErrorType = "invalid_grant" InvalidRequest OAuth2ErrorType = "invalid_request" InvalidScope OAuth2ErrorType = "invalid_scope" MethodNotAllowed OAuth2ErrorType = "method_not_allowed" NotFound OAuth2ErrorType = "not_found" ServerError OAuth2ErrorType = "server_error" UnsupportedGrantType OAuth2ErrorType = "unsupported_grant_type" UnsupportedMediaType OAuth2ErrorType = "unsupported_media_type" UnsupportedResponseType OAuth2ErrorType = "unsupported_response_type" )