From 59db9d263fa906c5397893cc173728991f2f3a00 Mon Sep 17 00:00:00 2001 From: Siesta <124433727+siestaw@users.noreply.github.com> Date: Mon, 28 Jul 2025 21:09:06 +0200 Subject: [PATCH] feat: add custom 404 not found handler --- cmd/internal/http/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/internal/http/server.go b/cmd/internal/http/server.go index 524a89d..de215ce 100644 --- a/cmd/internal/http/server.go +++ b/cmd/internal/http/server.go @@ -8,12 +8,14 @@ import ( "github.com/siestaw/laterna/server/cmd/internal/db" "github.com/siestaw/laterna/server/cmd/internal/logger" "github.com/siestaw/laterna/server/cmd/internal/routes" + "github.com/siestaw/laterna/server/cmd/utils" ) func StartHTTPServer() { router := http.NewServeMux() routes.RegisterColorRoutes(router) routes.RegisterControllerRoutes(router) + router.HandleFunc("/", notFoundHandler) if !db.ControllerExists(0) { adminToken := db.CreateAdmin() @@ -29,3 +31,7 @@ func StartHTTPServer() { logger.HTTPLogger.Printf("HTTP Server running on :%v", port) http.ListenAndServe(fmt.Sprintf(":%d", port), router) } + +func notFoundHandler(w http.ResponseWriter, r *http.Request) { + utils.ErrorResponse(w, http.StatusNotFound, "Not found") +}