2018-06-30 00:57:05 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2020-03-09 18:17:55 +00:00
|
|
|
"github.com/statping/statping/types/core"
|
|
|
|
"github.com/statping/statping/types/services"
|
2018-06-30 00:57:05 +00:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2018-09-16 07:48:34 +00:00
|
|
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
2020-03-04 10:29:00 +00:00
|
|
|
if !core.App.Setup {
|
2018-06-30 00:57:05 +00:00
|
|
|
http.Redirect(w, r, "/setup", http.StatusSeeOther)
|
|
|
|
return
|
|
|
|
}
|
2020-03-04 10:29:00 +00:00
|
|
|
ExecuteResponse(w, r, "base.gohtml", core.App, nil)
|
2018-06-30 00:57:05 +00:00
|
|
|
}
|
2018-08-23 07:28:48 +00:00
|
|
|
|
2018-11-06 01:34:02 +00:00
|
|
|
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
health := map[string]interface{}{
|
2020-03-04 10:29:00 +00:00
|
|
|
"services": len(services.All()),
|
2019-03-16 22:55:45 +00:00
|
|
|
"online": true,
|
2020-03-04 10:29:00 +00:00
|
|
|
"setup": core.App.Setup,
|
2018-11-06 01:34:02 +00:00
|
|
|
}
|
2019-03-02 01:33:41 +00:00
|
|
|
returnJson(health, w, r)
|
2018-11-06 01:34:02 +00:00
|
|
|
}
|