Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = web.NewRequestError( errors.New("you are not authorized for that action"), http.StatusForbidden, )
ErrForbidden is returned when an authenticated user does not have a sufficient role for an action.
Functions ¶
func Authenticate ¶
func Authenticate(authenticator *auth.Authenticator) web.Middleware
Authenticate validates a JWT from the `Authorization` header.
func Errors ¶
func Errors(log *log.Logger) 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 HasRole ¶
func HasRole(roles ...string) web.Middleware
HasRole validates that an authenticated user has at least one role from a specified list. This method constructs the actual function that is used.
func Logger ¶
func Logger(log *log.Logger) web.Middleware
Logger writes some information about the request to the logs in the format: TraceID : (200) GET /foo -> IP ADDR (latency)
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.