Return 404 if Next does not match

pull/431/head
Fenny 2020-06-01 13:36:51 +02:00
parent 705b05216a
commit f9c08818ed
2 changed files with 4 additions and 2 deletions

View File

@ -87,6 +87,8 @@ func (app *App) next(ctx *Ctx) bool {
// Stop scanning the stack
return true
}
ctx.SendStatus(404)
ctx.SendString("Cannot " + ctx.method + " " + ctx.pathOriginal)
return false
}

View File

@ -179,10 +179,10 @@ func registerDummyRoutes(app *App) {
// go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4
func Benchmark_Router_NotFound(b *testing.B) {
app := New()
registerDummyRoutes(app)
app.Use(func(c *Ctx) {
c.Next()
})
registerDummyRoutes(app)
c := &fasthttp.RequestCtx{}
c.Request.Header.SetMethod("DELETE")