Documentation ¶
Overview ¶
Package middleware provides support for composing on demand and reusable filters/middleware
See github.com/shelakel/go-middleware/example for an example on how Compose is used to create middleware and pre/post filters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compose ¶
func Compose(middleware ...interface{}) http.HandlerFunc
Compose chains together the middleware and returns a http.HandlerFunc (which is compatible with http.Handler). Allowed middleware variants include: func(http.ResponseWriter, *http.Request, func(http.ResponseWriter, *http.Request)), func(http.ResponseWriter, *http.Request, http.HandlerFunc), func(http.ResponseWriter, *http.Request, http.Handler), Middleware, MiddlewareFunc, func(http.ResponseWriter, *http.Request), http.HandlerFunc, http.Handler and func(http.Handler) http.Handler.
Types ¶
type Middleware ¶
type Middleware interface {
Process(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}
Middleware allows for creating reusable middleware that require initial configuration
type MiddlewareFunc ¶
type MiddlewareFunc func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
The MiddlewareFunc type is an adapter to allow the use of ordinary functions as Middleware. If f is a function with the appropriate signature, MiddlewareFunc(f) is a Middleware object that calls f.
func (MiddlewareFunc) Process ¶
func (fn MiddlewareFunc) Process(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Process calls f(w, r, next).
Directories ¶
Path | Synopsis |
---|---|
Package context allows for storing values on a *Request and is a middleware implementation of github.com/gorilla/context.
|
Package context allows for storing values on a *Request and is a middleware implementation of github.com/gorilla/context. |