2019-01-17 14:09:13 -02:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/ant0ine/go-json-rest/rest"
|
|
|
|
|
"github.com/openaccounting/oa-server/core/model"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @api {get} /health-check Get system health status
|
2019-03-27 01:49:26 -03:00
|
|
|
* @apiVersion 1.2.0
|
2019-01-17 14:09:13 -02:00
|
|
|
* @apiName GetSystemHealthStatus
|
|
|
|
|
* @apiGroup SystemHealth
|
|
|
|
|
*
|
|
|
|
|
*
|
2019-03-27 01:49:26 -03:00
|
|
|
* @apiHeader {String} Accept-Version: 1.2.0 semver versioning
|
2019-01-17 14:09:13 -02:00
|
|
|
*
|
|
|
|
|
* @apiSuccess {String} database Database status: "ok"; "fail"
|
|
|
|
|
* @apiSuccess {String} api API status: "ok"
|
|
|
|
|
*
|
|
|
|
|
* @apiSuccessExample Success-Response:
|
|
|
|
|
* HTTP/1.1 200 OK
|
|
|
|
|
* {
|
|
|
|
|
* "database": "ok",
|
|
|
|
|
* "api": "ok",
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* @apiUse InternalServerError
|
|
|
|
|
*/
|
|
|
|
|
func GetSystemHealthStatus(w rest.ResponseWriter, r *rest.Request) {
|
|
|
|
|
status := map[string]string{
|
|
|
|
|
"database": "ok",
|
|
|
|
|
"api": "ok",
|
|
|
|
|
}
|
|
|
|
|
if err := model.Instance.PingDatabase(); err != nil {
|
|
|
|
|
status["database"] = "fail"
|
|
|
|
|
}
|
|
|
|
|
w.WriteJson(status)
|
|
|
|
|
}
|