Jeffrey Paul
61228b4586
Some checks failed
continuous-integration/drone/push Build is failing
Co-authored-by: sneak <sneak@sneak.berlin> Reviewed-on: #14
31 lines
813 B
Go
31 lines
813 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func (s *server) handleHealthCheck() http.HandlerFunc {
|
|
type response struct {
|
|
Status string `json:"status"`
|
|
Now string `json:"now"`
|
|
UptimeSeconds int64 `json:"uptime_seconds"`
|
|
UptimeHuman string `json:"uptime_human"`
|
|
Version string `json:"version"`
|
|
Appname string `json:"appname"`
|
|
Maintenance bool `json:"maintenance_mode"`
|
|
}
|
|
return func(w http.ResponseWriter, req *http.Request) {
|
|
resp := &response{
|
|
Status: "ok",
|
|
Now: time.Now().UTC().Format(time.RFC3339Nano),
|
|
UptimeSeconds: int64(s.uptime().Seconds()),
|
|
UptimeHuman: s.uptime().String(),
|
|
Maintenance: s.maintenance(),
|
|
Appname: s.appname,
|
|
Version: s.version,
|
|
}
|
|
s.respondJSON(w, req, resp, 200)
|
|
}
|
|
}
|