1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

change getting method point after overriding method in premiddleware (#1182)

This commit is contained in:
takaya kusanagi 2018-08-29 10:50:58 +09:00 committed by Vishal Rana
parent b369096cac
commit 31e795315a

View File

@ -557,18 +557,17 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c := e.pool.Get().(*context)
c.Reset(r, w)
m := r.Method
h := NotFoundHandler
if e.premiddleware == nil {
e.router.Find(m, getPath(r), c)
e.router.Find(r.Method, getPath(r), c)
h = c.Handler()
for i := len(e.middleware) - 1; i >= 0; i-- {
h = e.middleware[i](h)
}
} else {
h = func(c Context) error {
e.router.Find(m, getPath(r), c)
e.router.Find(r.Method, getPath(r), c)
h := c.Handler()
for i := len(e.middleware) - 1; i >= 0; i-- {
h = e.middleware[i](h)