From 930e81bd7fd30a805995cd3b0348e7e45731106a Mon Sep 17 00:00:00 2001 From: Bennett Wetters Date: Sat, 4 Nov 2023 22:30:52 +0100 Subject: [PATCH] Improve log messages --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index f1916a5..97cc493 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ func main() { if err != nil { log.Fatalln("Could not parse provided JSON") } + if !slices.Contains(spaceApiResponse.APICompatibility, "14") { log.Fatalln("Provided JSON doesn't specify compatibility with API version 14") } @@ -75,7 +76,7 @@ func main() { body, err := io.ReadAll(r.Body) if err != nil { - log.Println("Failed to read body status update request from", r.RemoteAddr) + log.Println("Failed to read request body from", r.RemoteAddr) w.WriteHeader(http.StatusInternalServerError) _, _ = io.WriteString(w, "Failed reading HTTP request body") return @@ -83,6 +84,7 @@ func main() { newState, err := strconv.ParseBool(string(body)) if err != nil { + log.Println("Failed to parse request body from", r.RemoteAddr) w.WriteHeader(http.StatusBadRequest) _, _ = io.WriteString(w, "HTTP request body should either be true or false") return