Is your feature request related to a problem?
No
Describe the solution you'd like
Assuming that we have code like:
app := New()
app.Setting.HandleMethodNotAllowed = true
app.Post("/path", func(ctx *Ctx) {
ctx.Send("hello")
})
app.Listen(3000)
and when we use the wrong method:
curl localhost:3000/path -I
> HTTP/1.1 405 Method Not Allowed
> Date: Sat, 20 Jun 2020 08:54:13 GMT
> Content-Type: text/plain; charset=utf-8
> Content-Length: 18
Additional context
We could add a boolean option in Settings named MethodNotAllowed bool and if set to true, instead of sending a 404 it will check the stack if it matches a different method and returns a 405 Method Not Allowed with the correct Allow header https://tools.ietf.org/html/rfc2616#section-10.4.6
Yes, that鈥檚 my intention:smile:
Fiber will respond with a 405 by default if another method is available on the same path.
This feature will be shipped in v1.12.1 next week, thank you for your suggestion 馃コ
@Fenny I use 1.12.4, but I can't see the 405 response you described, here is my code:
func InitRoute(app *fiber.App) {
v1 := app.Group("/v1")
app.Get("/v2", func(ctx *fiber.Ctx) {}) // /v2
v1.Get("/v2", func(ctx *fiber.Ctx) {}) // /v1/v2
}
app.Get (200)

app.Post (405 but 404)

v1.Get (200)

v1.Post (405 but 404)

@Aoi-hosizora, thank you for your detailed bug report. Do you mind creating a separate issue regarding this matter?
@Fenny Yes, new issue: https://github.com/gofiber/fiber/issues/556
Most helpful comment
We could add a boolean option in Settings named
MethodNotAllowedbooland if set to true, instead of sending a 404 it will check the stack if it matches a different method and returns a405 Method Not Allowedwith the correctAllowheader https://tools.ietf.org/html/rfc2616#section-10.4.6