From 2a909903fc21b470d4785a2c25742ad124d07ca8 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Mon, 16 Oct 2023 14:57:36 +0200 Subject: [PATCH] Change http status error codes This is to be clearer in response logs. --- internal/app/net/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/app/net/http.go b/internal/app/net/http.go index bce8238..5085670 100644 --- a/internal/app/net/http.go +++ b/internal/app/net/http.go @@ -185,7 +185,7 @@ func (s *Http) createMetric(w http.ResponseWriter, r *http.Request) { // Return a bad request if useragent is a bot if isBot(r.UserAgent()) { - http.Error(w, "Event request denied due to known bot", http.StatusBadRequest) + http.Error(w, "Event request denied due to known bot", http.StatusForbidden) return } @@ -207,7 +207,7 @@ func (s *Http) createMetric(w http.ResponseWriter, r *http.Request) { // Format error message errorMessage := fmt.Sprintf("%s - %s, Usage stats cannot be processed", eventRequest.Pid, err.Error()) - http.Error(w, errorMessage, http.StatusBadRequest) + http.Error(w, errorMessage, http.StatusUnprocessableEntity) return }