mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
Add /counts API to get total device count
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
@@ -92,6 +92,17 @@ func (srv *RttyServer) ListenAPI() error {
|
||||
handleUserConnection(srv, c)
|
||||
})
|
||||
|
||||
authorized.GET("/counts", func(c *gin.Context) {
|
||||
count := 0
|
||||
|
||||
srv.groups.Range(func(key, value any) bool {
|
||||
count += int(value.(*DeviceGroup).count.Load())
|
||||
return true
|
||||
})
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"count": count})
|
||||
})
|
||||
|
||||
authorized.GET("/groups", func(c *gin.Context) {
|
||||
groups := []string{""}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user