1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-25 21:05:56 +00:00

Update to 4.5.2

This commit is contained in:
Gerasimos Maropoulos
2016-10-11 22:35:12 +03:00
parent 40b000c20f
commit 9bce4e846a
7 changed files with 121 additions and 15 deletions

View File

@@ -665,3 +665,27 @@ func TestMuxCustomHandler(t *testing.T) {
expectedData4.DynamicPathParameter = param4
e.GET("/custom_handler_2/" + param4).Expect().Status(StatusOK).JSON().Equal(expectedData4)
}
func TestMuxFireMethodNotAllowed(t *testing.T) {
initDefault()
Default.Config.FireMethodNotAllowed = true
h := func(ctx *Context) {
ctx.Write("%s", ctx.MethodString())
}
Default.OnError(StatusMethodNotAllowed, func(ctx *Context) {
ctx.Write("Hello from my custom 405 page")
})
Get("/mypath", h)
Put("/mypath", h)
e := Tester(t)
e.GET("/mypath").Expect().Status(StatusOK).Body().Equal("GET")
e.PUT("/mypath").Expect().Status(StatusOK).Body().Equal("PUT")
// this should fail with 405 and catch by the custom http error
e.POST("/mypath").Expect().Status(StatusMethodNotAllowed).Body().Equal("Hello from my custom 405 page")
Close()
}