Memberships: Fix static file handler
Change-Id: I13b1cfefec5cb5b43a590d2f7e40f13e7b70aba7
diff --git a/core/auth/memberships/main.go b/core/auth/memberships/main.go
index 2e52323..c7df14e 100644
--- a/core/auth/memberships/main.go
+++ b/core/auth/memberships/main.go
@@ -28,9 +28,18 @@
//go:embed memberships-tmpl/*
var tmpls embed.FS
-//go:embed stat
+//go:embed static/*
var staticResources embed.FS
+type cachingHandler struct {
+ h http.Handler
+}
+
+func (h cachingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "max-age=604800")
+ h.h.ServeHTTP(w, r)
+}
+
type Store interface {
// Initializes store with admin user and their groups.
Init(user, email string, groups []string) error
@@ -673,7 +682,7 @@
e := make(chan error)
go func() {
r := mux.NewRouter()
- r.PathPrefix("/static/").Handler(http.FileServer(http.FS(staticResources)))
+ r.PathPrefix("/static/").Handler(cachingHandler{http.FileServer(http.FS(staticResources))})
r.HandleFunc("/group/{group-name}/add-user/", s.addUserToGroupHandler).Methods(http.MethodPost)
r.HandleFunc("/group/{parent-group}/add-child-group", s.addChildGroupHandler).Methods(http.MethodPost)
r.HandleFunc("/group/{owned-group}/add-owner-group", s.addOwnerGroupHandler).Methods(http.MethodPost)
diff --git a/core/auth/memberships/stat/main.css b/core/auth/memberships/static/main.css
similarity index 100%
rename from core/auth/memberships/stat/main.css
rename to core/auth/memberships/static/main.css
diff --git a/core/auth/memberships/stat/main.js b/core/auth/memberships/static/main.js
similarity index 100%
rename from core/auth/memberships/stat/main.js
rename to core/auth/memberships/static/main.js
diff --git a/core/auth/memberships/stat/pico.2.0.6.min.css b/core/auth/memberships/static/pico.2.0.6.min.css
similarity index 100%
rename from core/auth/memberships/stat/pico.2.0.6.min.css
rename to core/auth/memberships/static/pico.2.0.6.min.css