feat(security): #305 don't cache sensitive data
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 44s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 47s

This commit was merged in pull request #309.
This commit is contained in:
2024-12-12 00:02:55 +01:00
parent e81fa4b2b6
commit 380dd979f6
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package middleware
import (
"net/http"
"strings"
"me-fit/log"
)
func CacheControl(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
log.Info("path: %v", path)
cached := false
if strings.HasPrefix(path, "/static") {
cached = true
}
if !cached {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
}
next.ServeHTTP(w, r)
})
}