| 12345678910111213141516171819202122232425 |
- package web
- import (
- "embed"
- "io/fs"
- "net/http"
- )
- //go:embed static/*
- var staticFS embed.FS
- // Handler returns an http.Handler that serves the embedded web dashboard with no-cache headers.
- func Handler() http.Handler {
- sub, err := fs.Sub(staticFS, "static")
- if err != nil {
- panic(err)
- }
- fileServer := http.FileServer(http.FS(sub))
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
- w.Header().Set("Pragma", "no-cache")
- w.Header().Set("Expires", "0")
- fileServer.ServeHTTP(w, r)
- })
- }
|