Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶
type Middleware interface {
ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}
Middleware handler is an interface that objects can implement to be registered to serve as middleware in the stack. ServeHTTP should yield to the next middleware in the chain by invoking the next MiddlewareFunc. passed in.
func Wrap ¶
func Wrap(handler http.HandlerFunc) Middleware
Wrap converts a Handler into a Middleware so it can be used as a middleware. The next HandlerFunc is automatically called after the Middleware is executed.
type MiddlewareFunc ¶
type MiddlewareFunc func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
MiddlewareFunc is an adapter to allow the use of ordinary functions as middleware handlers. If f is a function with the appropriate signature, MiddlewareFunc(f) is a Middleware object that calls f.
func (MiddlewareFunc) ServeHTTP ¶
func (h MiddlewareFunc) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Stack ¶
Stack is a linked list stack of middleware
func (*Stack) Use ¶
func (s *Stack) Use(handler Middleware) *list.Element
Use adds a Middleware onto the middleware stack. Middlewares are invoked in the order they are added unless otherwise specified.
func (*Stack) UseHandler ¶
func (s *Stack) UseHandler(handler http.HandlerFunc) *list.Element
UseHandler adds a Handler onto the middleware stack. Handlers are invoked in the order they are added unless otherwise specified.