Documentation ¶
Index ¶
- func AfterResponse(hook func(http.ResponseWriter, *http.Request, int) error, skippers ...Skipper) func(http.Handler) http.Handler
- func BeforeRequest(hook func(*http.Request) error, skippers ...Skipper) func(http.Handler) http.Handler
- func Chain(middlewares ...Middleware) func(http.Handler) http.Handler
- func MethodAndPathSkipper(method string, re *regexp.Regexp) func(r *http.Request) bool
- func NegativeSkipper(skipper Skipper) func(*http.Request) bool
- func New(fn func(http.ResponseWriter, *http.Request, http.Handler), skippers ...Skipper) func(http.Handler) http.Handler
- func WithMiddlewares(handler http.Handler, middlewares ...Middleware) http.Handler
- type Middleware
- type Skipper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterResponse ¶
func AfterResponse(hook func(http.ResponseWriter, *http.Request, int) error, skippers ...Skipper) func(http.Handler) http.Handler
AfterResponse make a middleware which will call hook after the next handler
func BeforeRequest ¶
func BeforeRequest(hook func(*http.Request) error, skippers ...Skipper) func(http.Handler) http.Handler
BeforeRequest make a middleware which will call hook before the next handler
func Chain ¶
func Chain(middlewares ...Middleware) func(http.Handler) http.Handler
Chain make middlewares together
func MethodAndPathSkipper ¶
MethodAndPathSkipper returns skipper which will skip the middleware when r.Method equals the method and r.URL.Path matches the re when method is "*" it equals all http method
func NegativeSkipper ¶
NegativeSkipper returns skipper which is negative of the input skipper
func New ¶
func New(fn func(http.ResponseWriter, *http.Request, http.Handler), skippers ...Skipper) func(http.Handler) http.Handler
New make a middleware from fn which type is func(w http.ResponseWriter, r *http.Request, next http.Handler)
func WithMiddlewares ¶
func WithMiddlewares(handler http.Handler, middlewares ...Middleware) http.Handler
WithMiddlewares apply the middlewares to the handler. The middlewares are executed in the order that they are applied
Types ¶
type Middleware ¶
Middleware receives a handler and returns another handler. The returned handler can do some customized task according to the requirement