Add /counts API to get total device count

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2025-07-10 10:24:44 +08:00
parent 35a1fe2913
commit e91b262a46
+11
View File
@@ -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{""}