Add health endpoint
Adds a health endpoint for the service.
This commit is contained in:
parent
1b1419961b
commit
932fa7e376
|
@ -113,6 +113,8 @@ func main() {
|
|||
http.Handle("/", http.StripPrefix("/", fs))
|
||||
http.HandleFunc("/devices", handlerDevices)
|
||||
http.HandleFunc("/devices.json", handlerDevices)
|
||||
http.HandleFunc("/health.json", handlerHealth)
|
||||
http.HandleFunc("/health", handlerHealth)
|
||||
http.HandleFunc("/locations", handlerLocations)
|
||||
http.HandleFunc("/devices/", handlerDeviceQuery)
|
||||
fmt.Println("ot-browser serving: http://" + config.bindAddr)
|
||||
|
@ -143,6 +145,12 @@ func (c *Config) ReadFile(filename string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// handlerHealth - health endpoint - writes a health status message to the client
|
||||
func handlerHealth(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(`{"status":"ok"}`))
|
||||
}
|
||||
|
||||
func handlerDevices(w http.ResponseWriter, r *http.Request) {
|
||||
devs := make([]string, 0)
|
||||
for dev := range devices {
|
||||
|
|
Loading…
Reference in a new issue