diff options
Diffstat (limited to 'middleware/i18n.go')
-rw-r--r-- | middleware/i18n.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/middleware/i18n.go b/middleware/i18n.go index 5e33636..a30a9f6 100644 --- a/middleware/i18n.go +++ b/middleware/i18n.go @@ -28,12 +28,15 @@ func I18n(next http.Handler) http.Handler { } } - used := cmp.Or(p, i18n.DefaultPrinter) - ctx := context.WithValue(r.Context(), PrinterKey, used) + ctx := context.WithValue( + r.Context(), PrinterKey, cmp.Or(p, i18n.DefaultPrinter)) if p == pZero { + http.SetCookie(w, &http.Cookie{ + Name: "redirect", + Value: r.URL.Path, + }) templates.Root(nil, templates.SetLanguage()).Render(ctx, w) - /* TODO: Redirect the user back to where they came from */ } else { next.ServeHTTP(w, r.WithContext(ctx)) } |