Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMethodNotAllowed = &ErrorResponse{ StatusCode: http.StatusMethodNotAllowed, StatusText: "Method not allowed.", Message: "Method not allowed. Check the documentation for the correct endpoints.", } StatusCode: http.StatusUnauthorized, StatusText: "Unauthorized.", Message: "You're not authorized. Please check your credentials and try again.", } ErrNotFound = &ErrorResponse{ StatusCode: http.StatusNotFound, StatusText: "Resource not found.", Message: "Resource not found. Check the given identifier and try again.", } ErrBadRequest = &ErrorResponse{ StatusCode: http.StatusBadRequest, Message: "Bad request. Check the data sent in the request an try again.", } )
Functions ¶
func AddCustomErrorHandlerfunc ¶
func AddCustomErrorHandlerfunc(writer http.ResponseWriter, request *http.Request, value interface{})
func NewHandler ¶
func UnauthorizedHandler ¶
func UnauthorizedHandler(writer http.ResponseWriter)
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Err error `json:"-"` StatusCode int `json:"-"` StatusText string `json:"-"` Message string `json:"message"` }
func ErrorRenderer ¶
func ErrorRenderer(err error) *ErrorResponse
func ServerErrorRenderer ¶
func ServerErrorRenderer(err error) *ErrorResponse
func (*ErrorResponse) Render ¶
func (errorResponse *ErrorResponse) Render(writer http.ResponseWriter, request *http.Request) error
Click to show internal directories.
Click to hide internal directories.