middleware

package
v5.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const AuthUserKey key = 2

This, sadly is exported so we can inject fake loggers in tests. See routes.createRequest in server/api/routes/fakes.go

View Source
const LoggerKey key = 1

This, sadly is exported so we can inject fake loggers in tests. See routes.createRequest in server/api/routes/fakes.go

View Source
const RefreshTokenKey key = 3
View Source
const UserIPAddressKey key = 4

Variables

This section is empty.

Functions

func AsJSON

func AsJSON(next chain.Handler) chain.Handler

func Authenticate

func Authenticate(authenticator auth.Authenticator) chain.Middleware

Authenticate uses the provided authenticator to authenticate the request. On success, it yields to the next handler in the chain. On failure, it renders 401 Unauthorized.

func CheckAPIVersion

func CheckAPIVersion(serverVersion string) chain.Middleware

CheckAPIVersion checks that the request has a Draupnir-Version header with a version that matches the server's major version, and is equal to or lower than the minor version.

If the version doesn't match or the header is missing, it renders a 400 Bad Request.

func DefaultErrorRenderer

func DefaultErrorRenderer(next chain.Handler) chain.Handler

func GetAuthenticatedUser

func GetAuthenticatedUser(r *http.Request) (string, error)

func GetLogger

func GetLogger(r *http.Request) (log.Logger, error)

func GetUserIPAddress

func GetUserIPAddress(r *http.Request) (string, error)

func NewErrorHandler

func NewErrorHandler(logger log.Logger) chain.TerminatingMiddleware

func NewRequestLogger

func NewRequestLogger(logger log.Logger) chain.Middleware

func NewSentryReporter

func NewSentryReporter(sentry *raven.Client) chain.Middleware

func RecordUserIPAddress

func RecordUserIPAddress(logger log.Logger, trustedProxies []*net.IPNet, useXForwardedFor bool) chain.Middleware

func WithVersion

func WithVersion(next chain.Handler) chain.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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