Documentation ¶
Index ¶
- Variables
- func Chain(pattern string, handlers ...http.Handler)
- func ChainHandlers(handlers ...http.Handler) http.Handler
- func HandleChain(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)
- type ChainedHandler
- type ChainedHandlerFunc
- type CheckedResponseWriter
- type MuxChain
- type Muxer
Constants ¶
This section is empty.
Variables ¶
var Default = &MuxChain{}
Functions ¶
func ChainHandlers ¶
ChainHandlers chains together a set of handlers under an empty path.
func HandleChain ¶
HandleChain is the utility function chained handlers are responsible for calling when they are complete.
Types ¶
type ChainedHandler ¶
type ChainedHandler interface { http.Handler // ServeHTTPChain allows the handler to do its work and then call the remaining // handler chain. Implementers should call muxchain.HandleChain when complete. ServeHTTPChain(w http.ResponseWriter, req *http.Request, h ...http.Handler) }
ChainedHander allows implementers to call the handlers after them in a muxchain on their own. This allows handlers to defer functions until after the handler chain following them has been completed.
type ChainedHandlerFunc ¶
ChainedHandlerFunc represents a handler that is able to be chained to subsequent handlers.
func (ChainedHandlerFunc) ServeHTTP ¶
func (c ChainedHandlerFunc) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP allows ChainedHandlerFuncs to implement http.Handler
func (ChainedHandlerFunc) ServeHTTPChain ¶
func (c ChainedHandlerFunc) ServeHTTPChain(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)
ServeHTTPChain allows ChainedHandlerFuncs to be identified
type CheckedResponseWriter ¶
type CheckedResponseWriter interface { http.ResponseWriter Written() bool }
CheckedResponseWriter augments http.ResponseWriter to indicate if the response has been written to.
type MuxChain ¶
type MuxChain struct {
Muxer
}
func (*MuxChain) Chain ¶
Chain registers a pattern to a sequence of http.Handlers. Upon receiving a request, the mux chain will find the best matching pattern and call that chain of handlers. The handlers will be called in turn until one of them writes a response or the end of the chain is reached. If one of the handlers is a Muxer (e.g. http.ServeMux), the MuxChain will skip it if no pattern matches.