mirror of
https://github.com/labstack/echo.git
synced 2025-01-26 03:20:08 +02:00
Removed 405 handling for now
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
f839210454
commit
0f82a6439b
16
echo_test.go
16
echo_test.go
@ -383,14 +383,14 @@ func TestEchoNotFound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEchoMethodNotAllowed(t *testing.T) {
|
func TestEchoMethodNotAllowed(t *testing.T) {
|
||||||
e := New()
|
// e := New()
|
||||||
e.Get("/", func(c *Context) error {
|
// e.Get("/", func(c *Context) error {
|
||||||
return c.String(http.StatusOK, "Echo!")
|
// return c.String(http.StatusOK, "Echo!")
|
||||||
})
|
// })
|
||||||
r, _ := http.NewRequest(POST, "/", nil)
|
// r, _ := http.NewRequest(POST, "/", nil)
|
||||||
w := httptest.NewRecorder()
|
// w := httptest.NewRecorder()
|
||||||
e.ServeHTTP(w, r)
|
// e.ServeHTTP(w, r)
|
||||||
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
|
// assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEchoHTTPError(t *testing.T) {
|
func TestEchoHTTPError(t *testing.T) {
|
||||||
|
16
router.go
16
router.go
@ -284,7 +284,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
// Search order static > param > match-any
|
// Search order static > param > match-any
|
||||||
for {
|
for {
|
||||||
if search == "" {
|
if search == "" {
|
||||||
goto Found
|
goto End
|
||||||
}
|
}
|
||||||
|
|
||||||
pl := 0 // Prefix length
|
pl := 0 // Prefix length
|
||||||
@ -320,7 +320,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if search == "" {
|
if search == "" {
|
||||||
goto Found
|
goto End
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static node
|
// Static node
|
||||||
@ -364,26 +364,22 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.pvalues[len(cn.pnames)-1] = search
|
ctx.pvalues[len(cn.pnames)-1] = search
|
||||||
goto Found
|
goto End
|
||||||
}
|
}
|
||||||
|
|
||||||
Found:
|
End:
|
||||||
ctx.pnames = cn.pnames
|
ctx.pnames = cn.pnames
|
||||||
h = cn.findHandler(method)
|
h = cn.findHandler(method)
|
||||||
if cn.echo != nil {
|
if cn.echo != nil {
|
||||||
e = cn.echo
|
e = cn.echo
|
||||||
}
|
}
|
||||||
if h == nil {
|
if h == nil {
|
||||||
h = methodNotAllowedHandler
|
|
||||||
// Dig further for match-any, might have an empty value for *, e.g.
|
// 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 {
|
if cn = cn.findChildWithType(mtype); cn == nil {
|
||||||
|
h = notFoundHandler
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// println("here...")
|
|
||||||
// if cn.echo != nil {
|
|
||||||
// e = cn.echo
|
|
||||||
// }
|
|
||||||
h = cn.findHandler(method)
|
h = cn.findHandler(method)
|
||||||
ctx.pvalues[len(cn.pnames)-1] = ""
|
ctx.pvalues[len(cn.pnames)-1] = ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user