1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-12 01:22:21 +02:00

Middleware fix #407

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-03-16 08:24:25 -07:00
parent 93963365bf
commit e16b929900
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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)