From 668c151379ea1d9ff77505d74f751ed83a8af029 Mon Sep 17 00:00:00 2001 From: mihna123 Date: Fri, 4 Sep 2026 01:29:39 +0200 Subject: web: serve the stylesheet over a css route Embed the css directory alongside the templates and serve it with a FileServerFS mounted on GET /css/. The directory name matches the url prefix, so the file resolves without an fs.Sub and there is no error path to handle. Adding js later is the same one line. Cover the route in the handler tests, including that template sources stay unreachable and that the href the home page emits resolves to a file that is actually served. --- internal/server/handlers/handlers.go | 1 + 1 file changed, 1 insertion(+) (limited to 'internal/server/handlers/handlers.go') diff --git a/internal/server/handlers/handlers.go b/internal/server/handlers/handlers.go index 958ca30..f39c6d5 100644 --- a/internal/server/handlers/handlers.go +++ b/internal/server/handlers/handlers.go @@ -20,6 +20,7 @@ func Routes(conf *config.Config) *http.ServeMux { } mux := http.NewServeMux() mux.HandleFunc("GET /{$}", handler.home) + mux.Handle("GET /css/", http.FileServerFS(web.Files)) return mux } -- cgit v1.3.1