Server static files

This commit is contained in:
Maximilian Friedersdorff 2025-01-28 22:08:01 +00:00
parent 2ba0a0024e
commit 73a1c8bc02
7 changed files with 52 additions and 14 deletions

View file

@ -15,5 +15,21 @@ func main() {
notesRouter := views.GetRoutes("/notes")
router.Handle("/notes/", http.StripPrefix("/notes", notesRouter))
router.Handle(
conf.Conf.Static.Root,
logger(
http.StripPrefix(
"/static",
http.FileServer(http.Dir(conf.Conf.Static.Dir)),
),
),
)
log.Fatal(http.ListenAndServe(":8080", router))
}
func logger(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Print(r.URL.Path)
next.ServeHTTP(w, r)
})
}