From a94a89de960ff1faf500778ac60db3c9b22f53c0 Mon Sep 17 00:00:00 2001 From: idanoo Date: Sun, 20 Nov 2022 17:55:05 +1300 Subject: [PATCH] Updates --- main.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index f130a27..d19e68d 100644 --- a/main.go +++ b/main.go @@ -66,16 +66,10 @@ func handler(w http.ResponseWriter, r *http.Request) { fmt.Printf("Headers: %+v\n", r.Header) if len(bodyBytes) > 0 { - b, err := io.ReadAll(r.Body) - if err != nil { - log.Println(err) - return - } - var i IdentifyingRequest - err = json.Unmarshal(b, &i) + err := json.NewDecoder(r.Body).Decode(&i) if err != nil { - log.Println(err) + http.Error(w, err.Error(), http.StatusBadRequest) return }