// ServeHTTP builds the chain of handlers in order, closing the context along the way and executes it.
ServeHTTP builds the chain of handlers in order, closing the context along the way and executes it.
// ServeHTTP builds the chain of handlers in order closing the context along the way and executes it .
func (ch *ChainHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
	ctx := NewContext()
	handler := ch.handler(ctx)
	chain := ch.chain
	for chain != nil {
		if chain.middleware != nil {
			handler = chain.middleware(ctx, handler)
		}
		chain = chain.parent
	}
	handler.ServeHTTP(resp, req)
}
func ( ch * ChainHandler ) ServeHTTP ( resp http . ResponseWriter , req * http . Request ) { ctx := NewContext ( ) handler := ch . handler ( ctx ) chain := ch . chain for chain != nil { if chain . middleware != nil { handler = chain . middleware ( ctx , handler ) } chain = chain . parent } handler . ServeHTTP ( resp , req ) }
ServeHTTP builds the chain of handlers in order, closing the context along the way and executes it.
ServeHTTP builds the chain of handlers in order closing the context along the way and executes it .
// Build the context handler chain