ratelimiting!!!!
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user