Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMethodNotAllowed = &ErrorResponse{HTTPStatusCode: 405, StatusText: "Method not allowed."} //nolint
ErrMethodNotAllowed is default 405 router method not allowed
View Source
var ErrNotFound = &ErrorResponse{HTTPStatusCode: 404, StatusText: "Page not found."} //nolint
ErrNotFound is default router page not found
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrorResponse represents custom error response with statusText and error description
func ErrorForbidden ¶
func ErrorForbidden(err error) *ErrorResponse
ErrorForbidden return 403 with given error text
func ErrorInternalServer ¶
func ErrorInternalServer(err error) *ErrorResponse
ErrorInternalServer returns error response with status=500 and given error
func ErrorInvalidRequest ¶
func ErrorInvalidRequest(err error) *ErrorResponse
ErrorInvalidRequest return error response with status = 400 and given error
func ErrorNotAcceptable ¶
func ErrorNotAcceptable(err error) *ErrorResponse
ErrorNotAcceptable return 406 with given error text
func ErrorNotFound ¶
func ErrorNotFound(err error) *ErrorResponse
ErrorNotFound return 404 with given error text
func ErrorUnauthorized ¶
func ErrorUnauthorized(err error) *ErrorResponse
ErrorUnauthorized return 401 with given error text
func (*ErrorResponse) Render ¶
func (e *ErrorResponse) Render(w http.ResponseWriter, r *http.Request) error
Render realization method for render.renderer
Click to show internal directories.
Click to hide internal directories.