Documentation ¶
Index ¶
- Constants
- func AsJSON(next chain.Handler) chain.Handler
- func Authenticate(authenticator auth.Authenticator) chain.Middleware
- func CheckAPIVersion(serverVersion string) chain.Middleware
- func DefaultErrorRenderer(next chain.Handler) chain.Handler
- func GetAuthenticatedUser(r *http.Request) (string, error)
- func GetLogger(r *http.Request) (log.Logger, error)
- func NewErrorHandler(logger log.Logger) chain.TerminatingMiddleware
- func NewRequestLogger(logger log.Logger) chain.Middleware
- func NewSentryReporter(sentry *raven.Client) chain.Middleware
- func WithVersion(next chain.Handler) chain.Handler
Constants ¶
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
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
const RefreshTokenKey key = 3
Variables ¶
This section is empty.
Functions ¶
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 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
Types ¶
This section is empty.