Improve logging in handlers/sensors.go
This commit is contained in:
parent
1d30c16e46
commit
efbd55aac4
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue