Documentation ¶
Overview ¶
Package error provides error/logging functions that can be used in conjuction with http.Handler.
Index ¶
- func WriteError(rw http.ResponseWriter, code int, message string, err error)
- type HandlerError
- func BadRequest(message string, err error) *HandlerError
- func Forbidden(message string, err error) *HandlerError
- func InternalServerError(message string, err error) *HandlerError
- func NewError(statusCode int, message string, err error) *HandlerError
- func NotFound(message string, err error) *HandlerError
- func Unauthorized(message string, err error) *HandlerError
- type LoggerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(rw http.ResponseWriter, code int, message string, err error)
WriteError is a convenience function that creates a new HandlerError before calling writeErrorResponse. For use outside of the standard http handlers.
Types ¶
type HandlerError ¶
HandlerError represents an error raised inside a HTTP handler
func BadRequest ¶
func BadRequest(message string, err error) *HandlerError
func Forbidden ¶
func Forbidden(message string, err error) *HandlerError
func InternalServerError ¶
func InternalServerError(message string, err error) *HandlerError
func NotFound ¶
func NotFound(message string, err error) *HandlerError
func Unauthorized ¶
func Unauthorized(message string, err error) *HandlerError
func (*HandlerError) Error ¶
func (h *HandlerError) Error() string
type LoggerHandler ¶
type LoggerHandler func(http.ResponseWriter, *http.Request) *HandlerError
LoggerHandler defines a HTTP handler that includes a HandlerError return pointer
func (LoggerHandler) ServeHTTP ¶
func (handler LoggerHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.