Status checker

This commit is contained in:
mr
2024-08-21 11:57:45 +02:00
parent e9dc2ba043
commit f2461d853c
7 changed files with 55 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
package controllers
import (
"cloud.o-forge.io/core/oc-lib/tools"
tools "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web"
)
@@ -24,18 +24,22 @@ func (c *VersionController) GetAll() {
// @Success 200
// @router /status [get]
func (c *VersionController) Status() {
errStr := ""
api := tools.API{}
state, code, err := api.GetState()
if state == tools.ALIVE {
state, _, err = api.CheckRemoteAPIs([]string{})
}
if err != nil {
errStr = err.Error()
}
c.Data["json"] = map[string]interface{}{
"data": map[string]interface{}{
"state": state.String(),
"code": state,
},
"error": err.Error(),
"error": errStr,
"code": code,
}
c.ServeJSON()