middleware

package
v2.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AccountID string = "Account-Id"

AccountID serves as key for the account uuid in the context

View Source
const RoleIDs string = "Role-Ids"

RoleIDs serves as key for the roles in the context

Variables

View Source
var (
	// ErrInvalidToken is returned when the request token is invalid.
	ErrInvalidToken = errors.New("invalid or missing token")
)

Functions

func Cors

func Cors(opts ...cors.Option) func(http.Handler) http.Handler

Cors writes required cors headers to all requests.

func ExtractAccountUUID

func ExtractAccountUUID(opts ...account.Option) func(http.Handler) http.Handler

ExtractAccountUUID provides a middleware to extract the account uuid from the x-access-token header value and write it to the context. If there is no x-access-token the middleware is omitted.

func Logger

func Logger(logger log.Logger) func(http.Handler) http.Handler

Logger is a middleware to log http requests. It uses debug level logging and should be used by all services save the proxy (which uses info level logging).

func NoCache

func NoCache(next http.Handler) http.Handler

NoCache writes required cache headers to all requests.

func Secure

func Secure(next http.Handler) http.Handler

Secure writes required access headers to all requests.

func Static

func Static(root string, fs http.FileSystem, ttl int) func(http.Handler) http.Handler

Static is a middleware that serves static assets.

func Token

func Token(token string) func(http.Handler) http.Handler

Token provides a middleware to check access secured by a static token.

func TraceContext

func TraceContext(next http.Handler) http.Handler

TraceContext unpacks the request context looking for an existing trace id.

func Version

func Version(name, version string) func(http.Handler) http.Handler

Version writes the current version to the headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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