fix SetLocaleFromCookie comment

This commit is contained in:
perennial
2024-10-18 13:46:56 +11:00
parent 311b1de674
commit 8bf28ece2b
+6 -3
View File
@@ -7,11 +7,14 @@ import (
"codeberg.org/vnpower/pixivfe/v2/server/session"
)
// ProvideUserContext is a middleware that wraps an http.Handler
// to inject a user context into each incoming request.
// SetLocaleFromCookie is a middleware that extracts the user's locale preference
// from a cookie and sets it in the i18n package.
func SetLocaleFromCookie(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
i18n.SetLocale(session.GetCookie(r, session.Cookie_Locale))
locale := session.GetCookie(r, session.Cookie_Locale)
i18n.SetLocale(locale)
h.ServeHTTP(w, r)
})
}