threadr-rewritten/handlers/accept_cookie.go

22 lines
564 B
Go

package handlers
import (
"net/http"
"time"
)
func AcceptCookieHandler(app *App) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "threadr_cookie_banner",
Value: "accepted",
Path: "/",
Expires: time.Now().Add(30 * 24 * time.Hour),
})
from := r.URL.Query().Get("from")
if from == "" {
from = app.Config.ThreadrDir + "/"
}
http.Redirect(w, r, from, http.StatusFound)
}
}