oc-datacenter major oclib version + state checker
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
@@ -17,3 +18,29 @@ func (c *VersionController) GetAll() {
|
||||
c.Data["json"] = map[string]string{"version": "1"}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Status
|
||||
// @Description get status
|
||||
// @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": errStr,
|
||||
"code": code,
|
||||
}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user