From ade4a7ae91b1bd8367c1d51ac73396f1d91bc903 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 20 Jan 2023 20:08:19 -0600 Subject: [PATCH] Only attempt to parse the body when it is present. --- pkg/prom/middleware.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/prom/middleware.go b/pkg/prom/middleware.go index b90c1c87..6227884a 100644 --- a/pkg/prom/middleware.go +++ b/pkg/prom/middleware.go @@ -58,9 +58,11 @@ func preprocessRequest(r *http.Request) (*http.Request, error) { // All API requests should be JSON. var result map[string]interface{} - err = json.Unmarshal(body, &result) - if nil != err { - return nil, err + if len(body) > 0 { + err = json.Unmarshal(body, &result) + if nil != err { + return nil, err + } } // Pull out the method name, request ID, user ID, and address info.