diff --git a/context.go b/context.go index d293e295..31df4c56 100644 --- a/context.go +++ b/context.go @@ -367,6 +367,7 @@ func detectContentType(name string) (t string) { } func (c *context) reset(req engine.Request, res engine.Response) { + c.netContext = nil c.request = req c.response = res c.query = nil diff --git a/engine/standard/server.go b/engine/standard/server.go index 9d65034d..4b8d98fc 100644 --- a/engine/standard/server.go +++ b/engine/standard/server.go @@ -146,7 +146,10 @@ func WrapMiddleware(m func(http.Handler) http.Handler) echo.MiddlewareFunc { req := c.Request().(*Request) res := c.Response().(*Response) m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - res.ResponseWriter = w + res.ResponseWriter = &responseAdapter{ + ResponseWriter: res.ResponseWriter, + writer: c.Response(), + } req.Request = r err = next.Handle(c) })).ServeHTTP(res.ResponseWriter, req.Request)