mirror of
https://github.com/labstack/echo.git
synced 2025-01-12 01:22:21 +02:00
Support for 405 - method not allowed, closes #205
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
e619a97607
commit
cddd4a6676
16
echo_test.go
16
echo_test.go
@ -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) {
|
||||
|
@ -374,14 +374,16 @@ End:
|
||||
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.
|
||||
if cn = cn.findChildByKind(mkind); cn == nil {
|
||||
h = notFoundHandler
|
||||
return
|
||||
}
|
||||
h = cn.findHandler(method)
|
||||
ctx.pvalues[len(cn.pnames)-1] = ""
|
||||
if h = cn.findHandler(method); h == nil {
|
||||
h = methodNotAllowedHandler
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ReplicationController",
|
||||
"metadata": {
|
||||
"name": "echo"
|
||||
},
|
||||
"spec": {
|
||||
"replicas": 2,
|
||||
"selector": {
|
||||
"name": "echo"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"name": "echo"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"image": "gcr.io/fluent-anagram-95603/echo",
|
||||
"name": "echo",
|
||||
"ports": [{
|
||||
"containerPort": 5091
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Service",
|
||||
"metadata": {
|
||||
"name": "echo",
|
||||
"labels": {
|
||||
"name": "echo"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ports": [{
|
||||
"port": 5091
|
||||
}],
|
||||
"selector": {
|
||||
"name": "echo"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user