Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertErrorStatus(status int, err error) error
- func HandlerBuilder(i interface{}) (scaffold.Handler, error)
- func NewErrorStatus(status int, err string) error
- func SetErrorHandler(status int, handler ErrorHandler) scaffold.Middleware
- func SetErrorHandlerFunc(status int, ...) scaffold.Middleware
- type ErrorHandler
- type ErrorHandlerFunc
- type ErrorStatus
- type Handler
- type HandlerFunc
Constants ¶
const AllStatusCodes = 0
AllStatusCodes is a nice way of saying add for all status codes
Variables ¶
var DefaultErrorHandler = &defaultErrorHandler{}
DefaultErrorHandler is the default error handler
Functions ¶
func ConvertErrorStatus ¶
ConvertErrorStatus creates an error that implements ErrorStatus based off an error
func HandlerBuilder ¶
HandlerBuilder can be used to create a scaffold.Handler based on a Handler
func NewErrorStatus ¶
NewErrorStatus creates an error that implements ErrorStatus based off a string
func SetErrorHandler ¶
func SetErrorHandler(status int, handler ErrorHandler) scaffold.Middleware
SetErrorHandler returns Middleware that can be used to set the error handler
func SetErrorHandlerFunc ¶
func SetErrorHandlerFunc(status int, handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, status int, err error)) scaffold.Middleware
SetErrorHandlerFunc returns Middleware that can be used to set the error handler
Types ¶
type ErrorHandler ¶
type ErrorHandler interface {
ServeErrorPage(ctx context.Context, w http.ResponseWriter, r *http.Request, status int, err error)
}
ErrorHandler is an error handler
func GetErrorHandler ¶
func GetErrorHandler(ctx context.Context, status int) ErrorHandler
GetErrorHandler gets the error handler from the context or returns the default
type ErrorHandlerFunc ¶
type ErrorHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request, status int, err error)
ErrorHandlerFunc is an error handler
func (ErrorHandlerFunc) ServeErrorPage ¶
func (e ErrorHandlerFunc) ServeErrorPage(ctx context.Context, w http.ResponseWriter, r *http.Request, status int, err error)
ServeErrorPage Implements ErrorHandler.ServeErrorPage
type ErrorStatus ¶
ErrorStatus extends error adding a status method
type HandlerFunc ¶
HandlerFunc is similar to scaffold.HandlerFunc with the difference that an error is returned
func (HandlerFunc) CtxServeHTTP ¶
func (h HandlerFunc) CtxServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) error
CtxServeHTTP implements Handler.CtxServeHTTP