MCPcopy Create free account
hub / github.com/BryanMwangi/pine / wrapHandlers

Method wrapHandlers

pine.go:419–432  ·  view source on GitHub ↗

wrapHandlers applies all registered middleware to a handler slice. It always operates on the original handlers, so calling it multiple times produces a correctly single-wrapped result.

(handlers []Handler)

Source from the content-addressed store, hash-verified

417// It always operates on the original handlers, so calling it multiple
418// times produces a correctly single-wrapped result.
419func (server *Server) wrapHandlers(handlers []Handler) []Handler {
420 if len(server.middlewares) == 0 {
421 return handlers
422 }
423 wrapped := make([]Handler, len(handlers))
424 for k, h := range handlers {
425 w := h
426 for i := len(server.middlewares) - 1; i >= 0; i-- {
427 w = server.middlewares[i](w)
428 }
429 wrapped[k] = w
430 }
431 return wrapped
432}
433
434// Context returns the underlying request context.
435func (c *Ctx) Context() context.Context {

Callers 2

AddRouteMethod · 0.95
UseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected