middleware

package
v0.0.0-...-faaee1e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = web.NewRequestError(
	errors.New("not authorized"),
	http.StatusForbidden,
)

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

Functions

func Authenticate

func Authenticate(a *auth.Auth) web.Middleware

Authenticate middleware validates a JWT from the `Authorization` http header.

func Authorize

func Authorize(roles ...string) web.Middleware

Authorize middleware validates that an authenticated user has at least one role from a specified list of roles.

func Errors

func Errors(log *zap.SugaredLogger) web.Middleware

Errors handles errors coming out of the call chain (propagated by the innerHandler). It detects normal application errors which are used to respond to the client in a uniform way (trusted errors). Unexpected errors (status >= 500) are logged (untrusted errors).

func Logger

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

Logger writes some information about the request to the logs in the

func Metrics

func Metrics() web.Middleware

Metrics updates the program counters metrics.

func Panics

func Panics(log *zap.SugaredLogger) web.Middleware

Panics recovers from panics propagated by the innerHandler and converts the panic to an error so it is handled in Errors middleware (outer middleware).

Types

This section is empty.

Jump to

Keyboard shortcuts

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