feat: initialize template

This commit is contained in:
2026-03-02 22:36:47 +01:00
parent b4e8baabdc
commit dd5e32cc4d
62 changed files with 433 additions and 1016 deletions
+33
View File
@@ -0,0 +1,33 @@
package server
import (
"log/slog"
"net/http"
"time"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handler"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web"
)
func (s *Server) RegisterRoutes() http.Handler {
mux := http.NewServeMux()
fileServer := http.FileServer(http.FS(web.GetStaticFS()))
mux.Handle("/static/", http.StripPrefix("/static/", fileServer))
mux.Handle("/", handler.Home())
return s.loggingMiddleware(mux)
}
func (s *Server) loggingMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
next.ServeHTTP(w, r)
slog.Info("request",
"method", r.Method,
"path", r.URL.Path,
"duration", time.Since(start),
)
})
}