1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 05:32:57 +00:00

Send 404 Body Response

This commit is contained in:
Fenny 2020-06-01 11:24:22 +02:00
parent 39f6db6c47
commit 06c119d49a

View File

@ -5,6 +5,7 @@
package fiber
import (
"fmt"
"log"
"strings"
"time"
@ -98,8 +99,9 @@ func (app *App) handler(rctx *fasthttp.RequestCtx) {
// Find match in stack
match := app.next(ctx)
// Send a 404 by default if no route matched
if !match {
if !match || len(ctx.Fasthttp.Response.Body()) == 0 {
ctx.SendStatus(404)
ctx.SendString(fmt.Sprintf("Cannot %s %s", ctx.method, ctx.pathOriginal))
} else if app.Settings.ETag {
// Generate ETag if enabled
setETag(ctx, false)