Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMethodNotAllowed = &ErrorResponse{StatusCode: http.StatusMethodNotAllowed, Message: "Method not allowed"} ErrNotFound = &ErrorResponse{StatusCode: http.StatusNotFound, Message: "Resource not found"} ErrBadRequest = &ErrorResponse{StatusCode: http.StatusBadRequest, Message: "Bad request"} )
Functions ¶
func ItemContext ¶
ItemContext extracts the item ID from request
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Err error `json:"-"` StatusCode int `json:"-"` StatusText string `json:"status_text"` Message string `json:"message"` }
ErrorResponse structures the error response in the API
func ErrorRenderer ¶
func ErrorRenderer(err error) *ErrorResponse
ErrorRenderer handles rendering of Bad Request errors
func ServerErrorRenderer ¶
func ServerErrorRenderer(err error) *ErrorResponse
ServerErrorRenderer handles rendering of Internal Server errors
func (*ErrorResponse) Render ¶
func (e *ErrorResponse) Render(w http.ResponseWriter, r *http.Request) error
Render handles inserting status code to error response
Click to show internal directories.
Click to hide internal directories.