MCPcopy
hub / github.com/labstack/echo / WrapMiddleware

Function WrapMiddleware

echo.go:835–852  ·  view source on GitHub ↗

WrapMiddleware wraps `func(http.Handler) http.Handler` into `echo.MiddlewareFunc`

(m func(http.Handler) http.Handler)

Source from the content-addressed store, hash-verified

833
834// WrapMiddleware wraps `func(http.Handler) http.Handler` into `echo.MiddlewareFunc`
835func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc {
836 return func(next HandlerFunc) HandlerFunc {
837 return func(c *Context) (err error) {
838 req := c.Request()
839 req.Pattern = c.Path()
840 for _, p := range c.PathValues() {
841 req.SetPathValue(p.Name, p.Value)
842 }
843
844 m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
845 c.SetRequest(r)
846 c.SetResponse(NewResponse(w, c.echo.Logger))
847 err = next(c)
848 })).ServeHTTP(c.Response(), req)
849 return
850 }
851 }
852}
853
854func applyMiddleware(h HandlerFunc, middleware ...MiddlewareFunc) HandlerFunc {
855 for i := len(middleware) - 1; i >= 0; i-- {

Callers 1

TestEchoWrapMiddlewareFunction · 0.85

Calls 8

NewResponseFunction · 0.85
RequestMethod · 0.80
PathMethod · 0.80
PathValuesMethod · 0.80
ServeHTTPMethod · 0.80
SetRequestMethod · 0.80
SetResponseMethod · 0.80
ResponseMethod · 0.80

Tested by 1

TestEchoWrapMiddlewareFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…