You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 00:50:59 +13:00
Added GET /health-check and related files
This commit is contained in:
@@ -44,5 +44,6 @@ func GetRouter(auth *AuthMiddleware, prefix string) (rest.App, error) {
|
||||
rest.Post(prefix+"/orgs/:orgId/invites", auth.RequireAuth(PostInvite)),
|
||||
rest.Put(prefix+"/orgs/:orgId/invites/:inviteId", auth.RequireAuth(PutInvite)),
|
||||
rest.Delete(prefix+"/orgs/:orgId/invites/:inviteId", auth.RequireAuth(DeleteInvite)),
|
||||
rest.Get(prefix+"/health-check", GetSystemHealthStatus),
|
||||
)
|
||||
}
|
||||
|
||||
38
core/api/syshealth.go
Normal file
38
core/api/syshealth.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
* @apiVersion 1.0.1
|
||||
* @apiName GetSystemHealthStatus
|
||||
* @apiGroup SystemHealth
|
||||
*
|
||||
*
|
||||
* @apiHeader {String} Accept-Version: 1.1.0 semver versioning
|
||||
*
|
||||
* @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)
|
||||
}
|
||||
Reference in New Issue
Block a user