From 8dd538daadc55a935e6dc205d9b2559830818c07 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 19 Apr 2024 14:50:18 +0200 Subject: use abstracted FS to get 404 page --- server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 5ed4561..9238c73 100644 --- a/server.go +++ b/server.go @@ -101,12 +101,12 @@ func main() { files := http.FS(fs) notFoundHandler := func(c *fiber.Ctx) error { c.Status(fiber.StatusNotFound).Type("html", "utf-8") - content, err := fs.ReadFile("public/404.html") + content, err := files.Open("public/404.html") if err != nil { - content = []byte("404 Not Found") c.Type("txt") + return c.SendString("404 Not Found") } - return c.Send(content) + return c.SendStream(content) } website.Get("/404.html", notFoundHandler) website.Use("/", filesystem.New(filesystem.Config{ -- cgit 1.4.1