Documentation ¶
Overview ¶
Package mid contains the set of middleware functions.
Index ¶
- func Authenticate(a *auth.Auth) web.MidHandler
- func Cors(origins []string) web.MidHandler
- func Errors(log *logger.Logger) web.MidHandler
- func GetClaims(ctx context.Context) auth.Claims
- func GetSubject(ctx context.Context) common.Address
- func Logger(log *logger.Logger) web.MidHandler
- func Metrics() web.MidHandler
- func Panics() web.MidHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate(a *auth.Auth) web.MidHandler
Authenticate validates a JWT from the `Authorization` header.
func Cors ¶
func Cors(origins []string) web.MidHandler
Cors sets the response headers needed for Cross-Origin Resource Sharing
func Errors ¶
func Errors(log *logger.Logger) web.MidHandler
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 GetSubject ¶
GetSubject provides access to the subject from the claims.
func Logger ¶
func Logger(log *logger.Logger) web.MidHandler
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.MidHandler
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.