Documentation ¶
Overview ¶
Package mid provides middleware that can be used by any service in this project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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 Cors ¶
func Cors(origin string) web.Middleware
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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.