ratelimiting!!!!

This commit is contained in:
2026-11-22 19:07:55 -05:00
parent 80a5ae1f69
commit 26fe94ca45
9 changed files with 199 additions and 14 deletions
+7 -2
View File
@@ -2,6 +2,7 @@ package pages
import (
"errors"
"fmt"
"html/template"
"log"
"math/rand/v2"
@@ -137,12 +138,16 @@ func FaqHandler(pages *Pages, cfg config.Config) http.HandlerFunc {
}
}
func (pages *Pages) HTTPError(w http.ResponseWriter, r *http.Request, message string, status int) {
func (pages *Pages) HTTPError(w http.ResponseWriter, r *http.Request, message string, status int, title ...string) {
if strings.Contains(r.Header.Get("Accept"), "text/html") {
t := fmt.Sprintf("%c", status)
if len(title) > 0 {
t = title[0]
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(status)
_ = pages.Templates.ExecuteTemplate(w, "result.html", map[string]any{
"Title": status,
"Title": t,
"Message": message,
})
return