aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/router.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2025-11-01 18:34:04 +0100
committerGabriel A. Giovanini <mail@gabrielgio.me>2025-11-01 18:34:04 +0100
commitc6f77e08b8a26ec740f3121edbb7a9d06c04ce20 (patch)
tree7155f98f89a8d7ba310416ca13170b3af172a509 /pkg/handler/router.go
parent49fc8733129028ff4a3537b9eb20f548f0e3e9e6 (diff)
downloadcerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.tar.gz
cerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.tar.bz2
cerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.zip
feat: Add session variable
This will allow the css to be refreshed once the server is restarted. This allows the admin to update the theme configuration and have it reflected in the browser.
Diffstat (limited to 'pkg/handler/router.go')
-rw-r--r--pkg/handler/router.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/handler/router.go b/pkg/handler/router.go
index cb5d6f5..1fbc4e3 100644
--- a/pkg/handler/router.go
+++ b/pkg/handler/router.go
@@ -55,7 +55,11 @@ func MountHandler(
}
mux.HandleFunc("/static/{file}", staticHandler)
- mux.HandleFunc(fmt.Sprintf("/static/theme%s.css", templates.Slug), cssStaticHandler) // add slug so css file can be cached forever.
+ // add slug and session so css file can be cached forever.
+ // Slug follow commit id, which is update every new version
+ // Session is update every time server restarts, this allows the css to be
+ // cached forever but refresh if the admin updates the server configuration.
+ mux.HandleFunc(fmt.Sprintf("/static/theme.%s%s.css", templates.Session, templates.Slug), cssStaticHandler)
mux.HandleFunc("/{name}/about/{$}", gitHandler.About)
mux.HandleFunc("/{name}", gitHandler.Multiplex)
mux.HandleFunc("/{name}/{rest...}", gitHandler.Multiplex)