From 234d88edd63d0d04571e80cb2adfe59e45c54bb8 Mon Sep 17 00:00:00 2001 From: Ada Date: Fri, 16 Feb 2024 22:41:29 +0100 Subject: [PATCH] :bug: fix 404 on first hit On first hit, Server() calls for the first time router(). As a result / and /static are only configured after first hit --- internal/httpServer/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/httpServer/server.go b/internal/httpServer/server.go index 3c4fa52..3d3ea96 100644 --- a/internal/httpServer/server.go +++ b/internal/httpServer/server.go @@ -17,7 +17,7 @@ type ServerConfig struct { } // Configure HTTP router -func (config ServerConfig) router(_ http.ResponseWriter, _ *http.Request) { +func (config ServerConfig) router() { WebConfig := plak.WebConfig{ DB: config.DB, UrlLength: config.UrlLength, @@ -45,7 +45,7 @@ func Config(listenAddress string) *http.Server { func (config ServerConfig) Server() { log.Println("Listening on " + config.HTTPServer.Addr) - http.HandleFunc("/", config.router) + config.router() log.Fatal(config.HTTPServer.ListenAndServe()) }