Documentation ¶
Overview ¶
Package mehhttp provides functionality for handling and responding errors.
Index ¶
Constants ¶
View Source
const ( // ErrCommunication is used for all problems regarding client communication. As // communication is unstable by nature, this should not be reported as classic // meh.ErrInternal. ErrCommunication meh.Code = "mehhttp-communication" // ErrServiceNotReachable is used for problems with requesting third-party // services. ErrServiceNotReachable meh.Code = "mehhttp-service-not-reachable" )
Variables ¶
This section is empty.
Functions ¶
func HTTPStatusCode ¶ added in v1.10.0
HTTPStatusCode retrieves the HTTP status code for the given error.
func LogAndRespondError ¶
LogAndRespondError logs the given meh.Error and responds using the status code mapping set via SetHTTPStatusCodeMapping. The responded message will always be empty.
func SetHTTPStatusCodeMapping ¶
func SetHTTPStatusCodeMapping(mapping HTTPStatusCodeMapper)
SetHTTPStatusCodeMapping sets the mapping of meh.Code to HTTP status code that is used in LogAndRespondError.
Types ¶
type HTTPStatusCodeMapper ¶
HTTPStatusCodeMapper maps a meh.Code to HTTP status code. Used for example in LogAndRespondError.
Click to show internal directories.
Click to hide internal directories.