//go:build dev package resources import ( "log/slog" "net/http" "os" "path/filepath" ) func Handler() http.Handler { slog.Info("static assets are being served directly", "path", StaticDirectoryPath) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-store") http.StripPrefix("/static/", http.FileServerFS(os.DirFS(StaticDirectoryPath))).ServeHTTP(w, r) }) } func StaticPath(path string) string { return "/static/" + path } // ReadStatic reads a static file's raw bytes by its unhashed path (e.g. // "js/sw.js"), from disk in dev. Mirrors the prod variant so callers serving // stable, non-fingerprinted asset URLs work the same in both builds. func ReadStatic(path string) ([]byte, error) { return os.ReadFile(filepath.Join(StaticDirectoryPath, path)) }