Compare commits
No commits in common. "2fb2e5f151e8bd4845885fdea099fef311faf4c2" and "cf9678d7126e1951f9e4aabaa30d7350eb76973b" have entirely different histories.
2fb2e5f151
...
cf9678d712
|
@ -27,7 +27,7 @@ func Root(resp *types.SpaceAPIResponseV14) func(http.ResponseWriter, *http.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
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)
|
_, _ = w.Write(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -33,5 +34,7 @@ func EnvironmentSensor(
|
||||||
// Set SpaceAPI response values
|
// Set SpaceAPI response values
|
||||||
resp.Value = newState
|
resp.Value = newState
|
||||||
resp.LastChange = time.Now().Unix()
|
resp.LastChange = time.Now().Unix()
|
||||||
|
|
||||||
|
_, _ = io.WriteString(w, "Update Successful")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -32,5 +33,7 @@ func StateOpen(
|
||||||
// Set SpaceAPI response values
|
// Set SpaceAPI response values
|
||||||
resp.Open = newState
|
resp.Open = newState
|
||||||
resp.LastChange = time.Now().Unix()
|
resp.LastChange = time.Now().Unix()
|
||||||
|
|
||||||
|
_, _ = io.WriteString(w, "Update Successful")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func updateEndpointValidator(
|
||||||
// Check BasicAuth credentials
|
// Check BasicAuth credentials
|
||||||
username, password, ok := r.BasicAuth()
|
username, password, ok := r.BasicAuth()
|
||||||
if !ok || !util.CheckCredentials(authDB, validCredentials, username, password) {
|
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)
|
http.Error(w, "", http.StatusUnauthorized)
|
||||||
return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password))
|
return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue