MCPcopy
hub / github.com/caddyserver/caddy / Compile

Method Compile

modules/caddyhttp/routes.go:239–249  ·  view source on GitHub ↗

Compile prepares a middleware chain from the route list. This should only be done either once during provisioning for top-level routes, or on each request just before the middleware chain is executed for subroutes.

(next Handler)

Source from the content-addressed store, hash-verified

237// for top-level routes, or on each request just before the
238// middleware chain is executed for subroutes.
239func (routes RouteList) Compile(next Handler) Handler {
240 mid := make([]Middleware, 0, len(routes))
241 for _, route := range routes {
242 mid = append(mid, wrapRoute(route))
243 }
244 stack := next
245 for _, middleware := range slices.Backward(mid) {
246 stack = middleware(stack)
247 }
248 return stack
249}
250
251// wrapRoute wraps route with a middleware and handler so that it can
252// be chained in and defer evaluation of its matchers to request-time.

Callers

nothing calls this directly

Calls 1

wrapRouteFunction · 0.85

Tested by

no test coverage detected