mirror of
https://github.com/labstack/echo.git
synced 2025-04-19 12:12:51 +02:00
Deferred defer
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
2342df3e61
commit
055200818a
2
echo.go
2
echo.go
@ -198,7 +198,6 @@ func (e *Echo) Index(file string) {
|
|||||||
|
|
||||||
func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
h, c, echo := e.Router.Find(r.Method, r.URL.Path)
|
h, c, echo := e.Router.Find(r.Method, r.URL.Path)
|
||||||
defer e.pool.Put(c)
|
|
||||||
if echo != nil {
|
if echo != nil {
|
||||||
e = echo
|
e = echo
|
||||||
}
|
}
|
||||||
@ -212,6 +211,7 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
// Handler
|
// Handler
|
||||||
h(c)
|
h(c)
|
||||||
|
e.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run a server
|
// Run a server
|
||||||
|
@ -216,11 +216,11 @@ func (r *router) Find(method, path string) (h HandlerFunc, c *Context, echo *Ech
|
|||||||
|
|
||||||
func (r *router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (r *router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
h, c, _ := r.Find(req.Method, req.URL.Path)
|
h, c, _ := r.Find(req.Method, req.URL.Path)
|
||||||
defer r.echo.pool.Put(c)
|
|
||||||
c.Response.ResponseWriter = w
|
c.Response.ResponseWriter = w
|
||||||
if h != nil {
|
if h != nil {
|
||||||
h(c)
|
h(c)
|
||||||
} else {
|
} else {
|
||||||
r.echo.notFoundHandler(c)
|
r.echo.notFoundHandler(c)
|
||||||
}
|
}
|
||||||
|
r.echo.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user