summaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go35
1 files changed, 1 insertions, 34 deletions
diff --git a/main.go b/main.go
index 77d301c..e0c73e6 100644
--- a/main.go
+++ b/main.go
@@ -38,12 +38,8 @@ func main() {
mux.Handle("GET /favicon.ico", fs)
mux.Handle("GET /fonts/", fs)
mux.Handle("GET /style.css", fs)
- mux.Handle("GET /", middleware.Pipe(
- middleware.Theme,
- middleware.I18n,
- )(http.HandlerFunc(finalHandler)))
+ mux.Handle("GET /", middleware.I18n(http.HandlerFunc(finalHandler)))
mux.Handle("POST /language", http.HandlerFunc(setUserLanguage))
- mux.Handle("POST /theme", http.HandlerFunc(setUserTheme))
portStr := ":" + strconv.Itoa(*port)
log.Println("Listening on", portStr)
@@ -101,32 +97,3 @@ func setUserLanguage(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, c.Value, http.StatusFound)
}
}
-
-func setUserTheme(w http.ResponseWriter, r *http.Request) {
- c, err := r.Cookie("theme")
- if errors.Is(err, http.ErrNoCookie) {
- w.WriteHeader(http.StatusBadRequest)
- fmt.Fprintf(w, "No ‘theme’ cookie exists")
- return
- }
-
- var theme string
-
- switch c.Value {
- case "dark":
- theme = "light"
- case "light":
- theme = "dark"
- default:
- w.WriteHeader(http.StatusBadRequest)
- fmt.Fprintf(w, "Theme ‘%s’ is invalid", c.Value)
- return
- }
-
- http.SetCookie(w, &http.Cookie{
- Name: "theme",
- Value: theme,
- MaxAge: math.MaxInt32,
- })
- http.Redirect(w, r, r.Referer(), http.StatusFound)
-}