diff --git a/internal/http/handlers.go b/internal/http/handlers.go index bf96025..897ae40 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -135,7 +135,7 @@ func (h *Handlers) GuestbookPost(w http.ResponseWriter, r *http.Request) { r.ParseForm() if !inmemdb.Solve(captcha.ID(r.FormValue("captcha_id")), captcha.Answer(r.FormValue("captcha_answer"))) { - h.ForbiddenError("wrong answer", "Here's your message:"+r.FormValue("message")) + h.ForbiddenError("Wrong answer given.", "Here's your message:"+r.FormValue("message"), w) return } @@ -146,14 +146,14 @@ func (h *Handlers) GuestbookPost(w http.ResponseWriter, r *http.Request) { entry, err = guestbook.NewEntry(r.FormValue("name"), r.FormValue("message"), r.FormValue("website"), r.FormValue("hide_website") != "") if err != nil { - h.InternalError(err.Error(), "Here's your message:"+r.FormValue("message")) + h.InternalError(err.Error(), "Here's your message:"+r.FormValue("message"), w) return } } if err = h.guestbookDB.NewEntry(entry); err != nil { - h.InternalError(err.Error(), "Here's your message:"+r.FormValue("message")) + h.InternalError(err.Error(), "Here's your message:"+r.FormValue("message"), w) return } @@ -174,11 +174,9 @@ func (h *Handlers) Robots(w http.ResponseWriter, r *http.Request) { /**** Errors ******************************************************************/ -func (h *Handlers) ForbiddenError(err, msg string) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusForbidden) - web.ForbiddenError("/ Forbidden", err, msg, w) - } +func (h *Handlers) ForbiddenError(err, msg string, w http.ResponseWriter) { + w.WriteHeader(http.StatusForbidden) + web.ForbiddenError("/ Forbidden", err, msg, w) } func (h *Handlers) NotFound(w http.ResponseWriter, r *http.Request) { @@ -186,11 +184,9 @@ func (h *Handlers) NotFound(w http.ResponseWriter, r *http.Request) { web.NotFound("Not Found", w) } -func (h *Handlers) InternalError(err, msg string) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusInternalServerError) - web.InternalError("/ Internal Error", err, msg, w) - } +func (h *Handlers) InternalError(err, msg string, w http.ResponseWriter) { + w.WriteHeader(http.StatusInternalServerError) + web.InternalError("/ Internal Error", err, msg, w) } /**** CAPTCHA *****************************************************************/