Documentation ¶
Index ¶
Constants ¶
View Source
const BadRequestStatusText = "There was a bad request."
View Source
const InternalServerErrorStatusText = "An internal server error has occurred."
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 NewHandler ¶
func NewHandler() *chi.Mux
func RenderError ¶
func UnauthorizedHandler ¶
func UnauthorizedHandler(writer http.ResponseWriter)
Types ¶
type ControllerHandler ¶
type ControllerHandler struct { Writer http.ResponseWriter Request *http.Request }
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 ServerErrorMsgRenderer ¶
func ServerErrorMsgRenderer(message string) *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.