add health check api

This commit is contained in:
MaysWind
2022-12-05 22:59:26 +08:00
parent fd7905833e
commit 6f88e6ef26
4 changed files with 35 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
package api
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
"github.com/mayswind/ezbookkeeping/pkg/errs"
"github.com/mayswind/ezbookkeeping/pkg/settings"
)
// HealthsApi represents health api
type HealthsApi struct{}
// Initialize a healths api singleton instance
var (
Healths = &HealthsApi{}
)
// HealthStatusHandler returns the health status of current service
func (a *HealthsApi) HealthStatusHandler(c *core.Context) (interface{}, *errs.Error) {
result := make(map[string]string)
result["version"] = settings.Version
result["commit"] = settings.CommitHash
result["status"] = "ok"
return result, nil
}