statping/handlers/index.go

39 lines
1.2 KiB
Go
Raw Normal View History

2018-12-04 05:57:11 +00:00
// Statping
2018-08-16 06:22:20 +00:00
// Copyright (C) 2018. Hunter Long and the project contributors
// Written by Hunter Long <info@socialeck.com> and the project contributors
//
2018-12-04 04:17:29 +00:00
// https://github.com/hunterlong/statping
2018-08-16 06:22:20 +00:00
//
// The licenses for most software and other practical works are designed
// to take away your freedom to share and change the works. By contrast,
// the GNU General Public License is intended to guarantee your freedom to
// share and change all versions of a program--to make sure it remains free
// software for all its users.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2018-06-30 00:57:05 +00:00
package handlers
import (
2018-12-04 04:17:29 +00:00
"github.com/hunterlong/statping/core"
2018-06-30 00:57:05 +00:00
"net/http"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
2020-02-17 17:45:33 +00:00
if !core.CoreApp.Setup {
2018-06-30 00:57:05 +00:00
http.Redirect(w, r, "/setup", http.StatusSeeOther)
return
}
2020-01-26 21:01:43 +00:00
ExecuteResponse(w, r, "index.html", core.CoreApp, 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{}{
"services": len(core.Services()),
2019-03-16 22:55:45 +00:00
"online": true,
2019-12-30 08:08:51 +00:00
"setup": core.CoreApp.Config != nil,
2018-11-06 01:34:02 +00:00
}
returnJson(health, w, r)
2018-11-06 01:34:02 +00:00
}