diff --git a/internal/httpx/request.go b/internal/httpx/request.go index 7a376e4..58f32b8 100644 --- a/internal/httpx/request.go +++ b/internal/httpx/request.go @@ -2,6 +2,8 @@ package httpx import ( "encoding/json" + "errors" + "io" "mime" "net/http" @@ -25,5 +27,10 @@ func DecodeJSONBody(w http.ResponseWriter, r *http.Request, requestID string, ds return false } + if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) { + WriteError(w, http.StatusBadRequest, dto.ErrorCodeInvalidRequest, "invalid request body", requestID) + return false + } + return true }