package web import ( _ "embed" "encoding/json" "io" "net/http" "lan-ups/internal/monitor" ) //go:embed static/index.html var dashboard string func Handler(snapshot func() monitor.Snapshot) http.Handler { mux := http.NewServeMux() mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") io.WriteString(w, dashboard) }) mux.HandleFunc("GET /api/status", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.Header().Set("Cache-Control", "no-store") json.NewEncoder(w).Encode(snapshot()) }) return mux }