From efbd55aac47f4dc3edaac10151e5d8107076a381 Mon Sep 17 00:00:00 2001 From: Bennett Wetters Date: Mon, 15 Jan 2024 22:31:29 +0100 Subject: [PATCH] Improve logging in handlers/sensors.go --- handlers/sensors.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handlers/sensors.go b/handlers/sensors.go index ec0a6aa..753574b 100644 --- a/handlers/sensors.go +++ b/handlers/sensors.go @@ -17,12 +17,12 @@ func EnvironmentSensor( resp *types.EnvironmentSensor, ) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { - body := updateEndpointValidator(authDB, validCredentials, w, r) + body := string(updateEndpointValidator(authDB, validCredentials, w, r)) // Parse request body - newState, err := strconv.ParseFloat(string(body), 64) + newState, err := strconv.ParseFloat(body, 64) if err != nil || math.IsInf(newState, 0) { - log.Println("Failed to parse request body from", r.RemoteAddr) + log.Println("Failed to parse request body from", r.RemoteAddr, "body:", body) w.WriteHeader(http.StatusBadRequest) _, _ = io.WriteString(w, "HTTP request body has to be a valid float64 value != +/-Inf") return