1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-03 22:59:09 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-11-16 07:57:40 -08:00
parent 0163cddab5
commit f09efac326
3 changed files with 41 additions and 13 deletions

View File

@@ -398,18 +398,10 @@ End:
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
c := r.echo.pool.Get().(*Context)
h, e := r.Find(req.Method, req.URL.Path, c)
c.reset(req, w, e)
// Chain middleware with handler in the end
for i := len(e.middleware) - 1; i >= 0; i-- {
h = e.middleware[i](h)
}
// Execute chain
h, _ := r.Find(req.Method, req.URL.Path, c)
c.reset(req, w, r.echo)
if err := h(c); err != nil {
e.httpErrorHandler(err, c)
r.echo.httpErrorHandler(err, c)
}
e.pool.Put(c)
r.echo.pool.Put(c)
}