middleware

package
v0.0.0-...-45d6836 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChain

func NewChain(finalHandler http.Handler, last Middleware, chain ...Middleware) http.Handler

NewChain creates a new chain of middlewares with a final handler

Last is the last Middleware in the call stack, the rest will be called in inverse order- (The last parameter is the first to be called)
Final handler is the original handler - not a middleware. it will be called last- after all the Middleware

Types

type LogMiddleware

type LogMiddleware struct {
	Log *log.Logger
}

LogMiddleware log all the requests in the provided log

type Middleware

type Middleware interface {
	// contains filtered or unexported methods
}

Middleware define the interface for middleware to implement

func NewMiddlewareChain

func NewMiddlewareChain(last Middleware, secondLast Middleware, chain ...Middleware) Middleware

NewMiddlewareChain creates a new chain of middlewares without a final handler- This works in the same way as NewChain, but returns a Middleware instead of a http Handler

type SecurityHeadersMiddleware

type SecurityHeadersMiddleware struct {
}

SecurityHeadersMiddleware add recomended security headers in the http response

type UserAuthMiddleware

type UserAuthMiddleware struct {
	JWTKey        []byte
	RefreshJTWKey []byte
	Log           debug.Logger
}

UserAuthMiddleware authenticate a user

Jump to

Keyboard shortcuts

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