This commit is contained in:
joy.zhou
2019-07-31 10:47:37 +08:00
parent 4c5a48a44b
commit 3a9bbcb58a

View File

@@ -22,5 +22,31 @@ func InitHTTPMoniter(b *Broker) {
c.JSON(200, &resp)
})
router.GET("api/v1/connections", func(c *gin.Context) {
num := 0
b.clients.Range(func(key, value interface{}) bool {
num++
return true
})
resp := map[string]int{
"code": 0,
"counts": num,
}
c.JSON(200, &resp)
})
router.GET("api/v1/nodes", func(c *gin.Context) {
num := 0
b.clients.Range(func(key, value interface{}) bool {
num++
return true
})
resp := map[string]int{
"code": 0,
"counts": num,
}
c.JSON(200, &resp)
})
router.Run(":8080")
}