diff --git a/handlers/root.go b/handlers/root.go index f68f5fd..e6ee447 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; charset=utf-8") + w.Header().Set("Content-Type", "application/json") _, _ = w.Write(response) } } diff --git a/handlers/sensors.go b/handlers/sensors.go index bd881fb..0c30346 100644 --- a/handlers/sensors.go +++ b/handlers/sensors.go @@ -1,6 +1,7 @@ package handlers import ( + "io" "log" "math" "net/http" @@ -33,5 +34,7 @@ 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 0ec9727..72384e5 100644 --- a/handlers/state.go +++ b/handlers/state.go @@ -1,6 +1,7 @@ package handlers import ( + "io" "log" "net/http" "strconv" @@ -32,5 +33,7 @@ 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 f29e8cc..ffc4801 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()["WWW-Authenticate"] = []string{"Basic realm=\"spaceapid\""} + w.Header().Set("WWW-Authenticate", "Basic realm=\"space-api\"") http.Error(w, "", http.StatusUnauthorized) return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password)) }