Documentation ¶
Index ¶
- type Chain
- func (chain *Chain) Append(cms ...ContextMiddleware) (newChain *Chain)
- func (chain *Chain) AppendChain(tail *Chain) (newChain *Chain)
- func (chain *Chain) Then(fn ContextHandlerFunc) (ch *ChainHandler)
- func (chain *Chain) ThenHandler(handler http.Handler) (ch *ChainHandler)
- func (chain *Chain) ThenHandlerFunc(fn func(http.ResponseWriter, *http.Request)) (ch *ChainHandler)
- type ChainHandler
- type Context
- type ContextHandler
- type ContextHandlerFunc
- type ContextMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain link context middlewares to each other. Chain are immutable and any operation on them returns a new Chain object.
func NewChain ¶
func NewChain(cms ...ContextMiddleware) (chain *Chain)
NewChain creates a new contextMiddleware chain.
func (*Chain) Append ¶
func (chain *Chain) Append(cms ...ContextMiddleware) (newChain *Chain)
Append add contextMiddleware(s) to the chain.
func (*Chain) AppendChain ¶
AppendChain duplicates a chain and links it to the current chain.
func (*Chain) Then ¶
func (chain *Chain) Then(fn ContextHandlerFunc) (ch *ChainHandler)
Then add a ContextHandlerFunc to the end of the chain and returns a http.Handler compliant ContextHandler
func (*Chain) ThenHandler ¶
func (chain *Chain) ThenHandler(handler http.Handler) (ch *ChainHandler)
ThenHandler add a http.Handler to the end of the chain and returns a http.Handler compliant ContextHandler
func (*Chain) ThenHandlerFunc ¶
func (chain *Chain) ThenHandlerFunc(fn func(http.ResponseWriter, *http.Request)) (ch *ChainHandler)
ThenHandlerFunc add a http.HandlerFunc to the end of the chain and returns a http.Handler compliant ContextHandler
type ChainHandler ¶
type ChainHandler struct {
// contains filtered or unexported fields
}
ChainHandler holds a chain and a final handler. It satisfy the http.Handler interface and can be served directly by a net/http server.
func (*ChainHandler) ServeHTTP ¶
func (ch *ChainHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)
ServeHTTP builds the chain of handlers in order, closing the context along the way and executes it.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context hold a map[interface{}]interface{} to pass along the middleware chain.
func (*Context) Delete ¶
func (ctx *Context) Delete(key interface{})
Delete remove a value from the context.
type ContextHandler ¶
ContextHandler is a constructor to close a Context into a http.Handler
type ContextHandlerFunc ¶
type ContextHandlerFunc func(ctx *Context, resp http.ResponseWriter, req *http.Request)
ContextHandlerFunc is a constructor to close a Context into a http.HandlerFunc
type ContextMiddleware ¶
ContextMiddleware is a constructor to close a Context into a middleware