MCPcopy
hub / github.com/go-chi/chi / chain

Function chain

chain.go:36–49  ·  chain.go::chain

chain builds a http.Handler composed of an inline middleware stack and endpoint handler in the order they are passed.

(middlewares []func(http.Handler) http.Handler, endpoint http.Handler)

Source from the content-addressed store, hash-verified

34// chain builds a http.Handler composed of an inline middleware stack and endpoint
35// handler in the order they are passed.
36func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
37 // Return ahead of time if there aren't any middlewares for the chain
38 if len(middlewares) == 0 {
39 return endpoint
40 }
41
42 // Wrap the end handler with the middleware chain
43 h := middlewares[len(middlewares)-1](endpoint)
44 for i := len(middlewares) - 2; i >= 0; i-- {
45 h = middlewares[i](h)
46 }
47
48 return h
49}

Callers 3

updateRouteHandlerMethod · 0.85
HandlerMethod · 0.85
HandlerFuncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected