Documentation ¶
Overview ¶
Package mid contains the set of middleware functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidID = errors.New("ID is not in its proper form")
)
Set of error variables for handling user group errors.
Functions ¶
func Authenticate ¶
func Authenticate(a *auth.Auth) web.Middleware
Authenticate validates a JWT from the `Authorization` header.
func Authorize ¶
func Authorize(a *auth.Auth, rule string) web.Middleware
Authorize validates that an authenticated user has at least one role from a specified list. This method constructs the actual function that is used.
func Errors ¶
func Errors(log *zap.SugaredLogger) web.Middleware
Errors handles errors coming out of the call chain. It detects normal application errors which are used to respond to the client in a uniform way. Unexpected errors (status >= 500) are logged.
func Logger ¶
func Logger(log *zap.SugaredLogger) web.Middleware
Logger creates a middleware that logs the request before and after it is processed.
func Panics ¶
func Panics() web.Middleware
Panics recovers from panics and converts the panic to an error so it is reported in Metrics and handled in Errors.
Types ¶
This section is empty.