Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = web.NewRequestError( errors.New("not authorized"), http.StatusForbidden, )
ErrForbidden is returned when an authenticated user does not have a sufficient role for an action.
Functions ¶
func Authenticate ¶
func Authenticate(a *auth.Auth) web.Middleware
Authenticate middleware validates a JWT from the `Authorization` http header.
func Authorize ¶
func Authorize(roles ...string) web.Middleware
Authorize middleware validates that an authenticated user has at least one role from a specified list of roles.
func Errors ¶
func Errors(log *zap.SugaredLogger) web.Middleware
Errors handles errors coming out of the call chain (propagated by the innerHandler). It detects normal application errors which are used to respond to the client in a uniform way (trusted errors). Unexpected errors (status >= 500) are logged (untrusted errors).
func Logger ¶
func Logger(log *zap.SugaredLogger) web.Middleware
Logger writes some information about the request to the logs in the
func Panics ¶
func Panics(log *zap.SugaredLogger) web.Middleware
Panics recovers from panics propagated by the innerHandler and converts the panic to an error so it is handled in Errors middleware (outer middleware).
Types ¶
This section is empty.