mirror of
https://github.com/labstack/echo.git
synced 2025-04-15 11:56:51 +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) {
|
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) {
|
||||||
|
@ -374,14 +374,16 @@ End:
|
|||||||
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.findChildByKind(mkind); cn == nil {
|
if cn = cn.findChildByKind(mkind); cn == nil {
|
||||||
h = notFoundHandler
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h = cn.findHandler(method)
|
|
||||||
ctx.pvalues[len(cn.pnames)-1] = ""
|
ctx.pvalues[len(cn.pnames)-1] = ""
|
||||||
|
if h = cn.findHandler(method); h == nil {
|
||||||
|
h = methodNotAllowedHandler
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
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…
x
Reference in New Issue
Block a user