middleware

package
v3.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 12 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

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 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 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