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

Removed 405 handling for now

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-10-06 13:56:01 -07:00
parent f839210454
commit 0f82a6439b
2 changed files with 14 additions and 18 deletions

View File

@ -383,14 +383,14 @@ func TestEchoNotFound(t *testing.T) {
}
func TestEchoMethodNotAllowed(t *testing.T) {
e := New()
e.Get("/", func(c *Context) error {
return c.String(http.StatusOK, "Echo!")
})
r, _ := http.NewRequest(POST, "/", nil)
w := httptest.NewRecorder()
e.ServeHTTP(w, r)
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
// e := New()
// e.Get("/", func(c *Context) error {
// return c.String(http.StatusOK, "Echo!")
// })
// r, _ := http.NewRequest(POST, "/", nil)
// w := httptest.NewRecorder()
// e.ServeHTTP(w, r)
// assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
}
func TestEchoHTTPError(t *testing.T) {

View File

@ -284,7 +284,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
// Search order static > param > match-any
for {
if search == "" {
goto Found
goto End
}
pl := 0 // Prefix length
@ -320,7 +320,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
}
if search == "" {
goto Found
goto End
}
// Static node
@ -364,26 +364,22 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
return
}
ctx.pvalues[len(cn.pnames)-1] = search
goto Found
goto End
}
Found:
End:
ctx.pnames = cn.pnames
h = cn.findHandler(method)
if cn.echo != nil {
e = cn.echo
}
if h == nil {
h = methodNotAllowedHandler
// Dig further for match-any, might have an empty value for *, e.g.
// serving a directory. Issue #207
// serving a directory. Issue #207.
if cn = cn.findChildWithType(mtype); cn == nil {
h = notFoundHandler
return
}
// println("here...")
// if cn.echo != nil {
// e = cn.echo
// }
h = cn.findHandler(method)
ctx.pvalues[len(cn.pnames)-1] = ""
}