Improve logging in handlers/state.go
This commit is contained in:
parent
efbd55aac4
commit
cc9cb8888c
|
@ -16,12 +16,12 @@ func StateOpen(
|
||||||
resp *types.SpaceState,
|
resp *types.SpaceState,
|
||||||
) func(http.ResponseWriter, *http.Request) {
|
) func(http.ResponseWriter, *http.Request) {
|
||||||
return func(w http.ResponseWriter, r *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
|
// Parse request body
|
||||||
newState, err := strconv.ParseBool(string(body))
|
newState, err := strconv.ParseBool(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
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)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
_, _ = io.WriteString(w, "HTTP request body should either be true or false")
|
_, _ = io.WriteString(w, "HTTP request body should either be true or false")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue