0
0
mirror of https://github.com/rls-moe/nyx synced 2025-08-19 06:18:38 +00:00

Added Moderation Tools, Captcha & Trollthrottle

This commit is contained in:
Tim Schuster
2017-03-13 16:04:00 +01:00
parent 69b0d20825
commit 4177901714
33 changed files with 9696 additions and 261 deletions

View File

@@ -13,6 +13,15 @@ func GetBaseCtx(r *http.Request) map[string]interface{} {
"CSRFToken": nosurf.Token(r),
}
if sess := GetSession(r); sess != nil {
val["Session"] = sess
}
err := r.URL.Query().Get("err")
if err != "" {
val["PreviousError"] = err
}
return val
}

View File

@@ -9,6 +9,10 @@ import (
func ConfigCtx(config *config.Config) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !config.IsHostNameValid(r.Host) {
return
}
r = r.WithContext(context.WithValue(r.Context(), configKey, config))
next.ServeHTTP(w, r)
})