middlewares

package
v0.0.0-...-4998d35 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessLogHandler

func AccessLogHandler(next http.Handler) http.Handler

AccessLogHandler log any HTTP request made to the application.

func DBFromContext

func DBFromContext(ctx context.Context) *mgo.Session

DBFromContext gets the db out of the context.

func FromAuthHeader

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

FromAuthHeader is a "TokenExtractor" that takes a give request and extracts the JWT token from the Authorization header.

func FromContext

func FromContext(ctx context.Context) log.Entry

FromContext gets the logger out of the context.

func FromRequest

func FromRequest(r *http.Request) log.Entry

FromRequest gets the logger from the request's context.

func IsValidAuth

func IsValidAuth(tokenString string) bool

IsValidAuth returns true if the token submitted is valid otherwise false.

func LoggingHandler

func LoggingHandler(next http.Handler) http.Handler

LoggingHandler set up Fields reused by every log instance.

func MongoHandler

func MongoHandler(next http.Handler) http.Handler

MongoHandler insert Mgo.session in context and serve the request.

func PanicRecoveryHandler

func PanicRecoveryHandler(next http.Handler) http.Handler

PanicRecoveryHandler avoids application restarts in case of panic error.

func TimeoutHandler

func TimeoutHandler(h http.Handler) http.Handler

TimeoutHandler end the request after 2 seconds.

func WithAuth

func WithAuth(next http.Handler) http.Handler

WithAuth filter requests depending on JWT token validity.

Types

This section is empty.

Jump to

Keyboard shortcuts

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