aboutsummaryrefslogtreecommitdiff
path: root/backend/router.go
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-10-05 14:31:20 +0200
committerWilliam Hergès <william@herges.fr>2025-10-05 14:57:45 +0200
commitaf6678decc6166f388d6e62edcb1407d2ce08f83 (patch)
tree11a14b74c34b948fce8f84be307e1f589c445cf7 /backend/router.go
parentb816fd4acf78de278dc254ffe264cacc83f67352 (diff)
feat(security): integrity on link and script
Diffstat (limited to 'backend/router.go')
-rw-r--r--backend/router.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/backend/router.go b/backend/router.go
index 01b8a07..65514ea 100644
--- a/backend/router.go
+++ b/backend/router.go
@@ -19,6 +19,7 @@ const (
Version = "0.2.0"
configKey = "config"
isUpdateKey = "is_update"
+ assetsFS = "assets_fs"
)
//go:embed templates
@@ -43,7 +44,7 @@ func SetupLogger(debug bool) {
slog.SetDefault(logger)
}
-func NewRouter(debug bool, cfg *Config) *chi.Mux {
+func NewRouter(debug bool, cfg *Config, assets fs.FS) *chi.Mux {
r := chi.NewRouter()
logLevel := slog.LevelWarn
@@ -67,6 +68,7 @@ func NewRouter(debug bool, cfg *Config) *chi.Mux {
r.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), configKey, cfg)
+ ctx = context.WithValue(ctx, assetsFS, assets)
next.ServeHTTP(w, r.WithContext(ctx))
})
})