Support app version on api.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -102,8 +102,16 @@ func TestAPIStatusAppHandler(t *testing.T) {
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
appVersion := "v1.0.0"
|
||||
SetVersion(appVersion)
|
||||
|
||||
r.GET("/api/stat/app").
|
||||
Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
||||
data := []byte(r.Body.String())
|
||||
|
||||
value, _ := jsonparser.GetString(data, "version")
|
||||
|
||||
assert.Equal(t, appVersion, value)
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ var Stats = stats.New()
|
||||
|
||||
// StatusApp is app status structure
|
||||
type StatusApp struct {
|
||||
Version string `json:"version"`
|
||||
QueueMax int `json:"queue_max"`
|
||||
QueueUsage int `json:"queue_usage"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
@@ -66,6 +67,7 @@ func InitAppStatus() error {
|
||||
func appStatusHandler(c *gin.Context) {
|
||||
result := StatusApp{}
|
||||
|
||||
result.Version = GetVersion()
|
||||
result.QueueMax = cap(QueueNotification)
|
||||
result.QueueUsage = len(QueueNotification)
|
||||
result.TotalCount = StatStorage.GetTotalCount()
|
||||
|
||||
Reference in New Issue
Block a user