package main import ( "embed" "io/fs" "net/http" ) // Webbklienten byggs in i binären — hela v2 är fortfarande en enda fil. // //go:embed web var webFiles embed.FS // mountWeb serves the embedded UI on / (the /api/* routes are more // specific and win in the mux). func mountWeb(mux *http.ServeMux) { sub, err := fs.Sub(webFiles, "web") if err != nil { panic(err) } fileServer := http.FileServerFS(sub) mux.Handle("GET /", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // UI:t behöver ingen auth (koden är publik i repot); API:t // skyddas separat. Strikt CSP så att inget externt kan läcka in. w.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'") fileServer.ServeHTTP(w, r) })) }