diff --git a/handlers/root.go b/handlers/root.go index e6ee447..f68f5fd 100644 --- a/handlers/root.go +++ b/handlers/root.go @@ -27,7 +27,7 @@ func Root(resp *types.SpaceAPIResponseV14) func(http.ResponseWriter, *http.Reque } w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") _, _ = w.Write(response) } } diff --git a/handlers/sensors.go b/handlers/sensors.go index 0c30346..bd881fb 100644 --- a/handlers/sensors.go +++ b/handlers/sensors.go @@ -1,7 +1,6 @@ package handlers import ( - "io" "log" "math" "net/http" @@ -34,7 +33,5 @@ func EnvironmentSensor( // Set SpaceAPI response values resp.Value = newState resp.LastChange = time.Now().Unix() - - _, _ = io.WriteString(w, "Update Successful") } } diff --git a/handlers/state.go b/handlers/state.go index 72384e5..0ec9727 100644 --- a/handlers/state.go +++ b/handlers/state.go @@ -1,7 +1,6 @@ package handlers import ( - "io" "log" "net/http" "strconv" @@ -33,7 +32,5 @@ func StateOpen( // Set SpaceAPI response values resp.Open = newState resp.LastChange = time.Now().Unix() - - _, _ = io.WriteString(w, "Update Successful") } } diff --git a/handlers/util.go b/handlers/util.go index ffc4801..f29e8cc 100644 --- a/handlers/util.go +++ b/handlers/util.go @@ -19,7 +19,7 @@ func updateEndpointValidator( // Check BasicAuth credentials username, password, ok := r.BasicAuth() if !ok || !util.CheckCredentials(authDB, validCredentials, username, password) { - w.Header().Set("WWW-Authenticate", "Basic realm=\"space-api\"") + w.Header()["WWW-Authenticate"] = []string{"Basic realm=\"spaceapid\""} http.Error(w, "", http.StatusUnauthorized) return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password)) }