From 35b48d29e69ee396b2fa3977d7bc466997a53380 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 13 Aug 2023 02:17:47 +0400 Subject: [PATCH] In main.go made use of handler's Error func and in Error() func added missing WriteHeader(). --- cmd/dwelling-home/main.go | 3 +-- internal/http/web_handlers.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/dwelling-home/main.go b/cmd/dwelling-home/main.go index 1bf2345..4aa0caa 100644 --- a/cmd/dwelling-home/main.go +++ b/cmd/dwelling-home/main.go @@ -54,8 +54,7 @@ func main() { r := httpr.New() r.NotFoundHandler = func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusNotFound) - web.ErrorXXX("/ Not Found", "", "", r.Referer(), http.StatusNotFound, w) + dwhttp.Error(w, http.StatusNotFound, "", "", r.Referer()) } r.ServeStatic("/assets/*filepath", web.Assets()) diff --git a/internal/http/web_handlers.go b/internal/http/web_handlers.go index d8be2f0..3b960d5 100644 --- a/internal/http/web_handlers.go +++ b/internal/http/web_handlers.go @@ -188,6 +188,7 @@ func SitemapXml(w http.ResponseWriter, r *http.Request) { } func Error(w http.ResponseWriter, code int, reason, message, referer string) { + w.WriteHeader(code) web.ErrorXXX("/ "+http.StatusText(code), reason, message, referer, code, w) }