Version: v0.0.0-...-fdd12d1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2020 License: Apache-2.0 Imports: 10 Imported by: 0



Package mid provides middleware that can be used by any service in this project.



This section is empty.


View Source
var ErrForbidden = web.NewRequestError(
	errors.New("you are not authorized for that action"),

ErrForbidden is returned when an authenticated user does not have a sufficient role for an action.


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.

func Logger

func Logger(log *log.Logger) web.Middleware

Logger writes some information about the request to the logs in the format: (200) GET /foo -> IP ADDR (latency)

func Metrics

func Metrics() web.Middleware

Metrics updates program counters.


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL