Schei! Encoding #20
4 changed files with 2 additions and 8 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue