Documentation ¶
Overview ¶
Package errors provides a nice way of handling http errors
Examples: To create an error:
err := errors.New(http.StatusBadRequest, "Something went wrong")
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRouteNotFound happens when no route was matched ErrRouteNotFound = New(http.StatusNotFound, "no API found with those values") // ErrInvalidID represents an invalid identifier ErrInvalidID = New(http.StatusBadRequest, "please provide a valid ID") )
Functions ¶
func Handler ¶
func Handler(w http.ResponseWriter, err interface{})
Handler marshals an error to JSON, automatically escaping HTML and setting the Content-Type as application/json.
func NotFound ¶
func NotFound(w http.ResponseWriter, r *http.Request)
NotFound handler is called when no route is matched
func RecoveryHandler ¶
func RecoveryHandler(w http.ResponseWriter, r *http.Request, err interface{})
RecoveryHandler handler is used when a panic happens
Types ¶
Click to show internal directories.
Click to hide internal directories.