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

Function wrapMiddleware

modules/caddyhttp/routes.go:331–341  ·  view source on GitHub ↗

wrapMiddleware wraps mh such that it can be correctly appended to a list of middleware in preparation for compiling into a handler chain.

(ctx caddy.Context, mh MiddlewareHandler)

Source from the content-addressed store, hash-verified

329// appended to a list of middleware in preparation for
330// compiling into a handler chain.
331func wrapMiddleware(ctx caddy.Context, mh MiddlewareHandler) Middleware {
332 return func(next Handler) Handler {
333 return HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
334 // EXPERIMENTAL: Trace each module that gets invoked
335 if server, ok := r.Context().Value(ServerCtxKey).(*Server); ok && server != nil {
336 server.logTrace(mh)
337 }
338 return mh.ServeHTTP(w, r, next)
339 })
340 }
341}
342
343// MatcherSet is a set of matchers which
344// must all match in order for the request

Callers 1

ProvisionHandlersMethod · 0.85

Calls 4

HandlerFuncFuncType · 0.85
logTraceMethod · 0.80
ServeHTTPMethod · 0.65
ValueMethod · 0.45

Tested by

no test coverage detected