From 23b6ff7da5d9b8e337d499cf91ef1a69186afec6 Mon Sep 17 00:00:00 2001 From: jackmc Date: Thu, 28 Sep 2023 15:53:59 +0100 Subject: [PATCH] feat: bad request on invalid json --- api/userapi/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/userapi/user.go b/api/userapi/user.go index 4bb393e..7af05c1 100644 --- a/api/userapi/user.go +++ b/api/userapi/user.go @@ -94,7 +94,7 @@ func (h *UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { WithField("body", string(reqData)). Error("failed to get user data from request body") - w.WriteHeader(http.StatusInternalServerError) + w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) return @@ -168,7 +168,7 @@ func (h *UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { WithError(err). Error("failed to unmarshal user data from request body") - w.WriteHeader(http.StatusInternalServerError) + w.WriteHeader(http.StatusBadRequest) w.Write(utils.ToRAWJSON(api.HTTPError{Error: err.Error()})) return