From cfd72743f35ec84d9186460e07ff522fdde861d6 Mon Sep 17 00:00:00 2001 From: Eccentric Date: Sat, 3 Feb 2024 15:08:16 +0000 Subject: [PATCH] Add another useful endpoint --- handlers/snow.go | 11 +++++++++++ main.go | 1 + 2 files changed, 12 insertions(+) diff --git a/handlers/snow.go b/handlers/snow.go index 5e1f684..7a4876e 100644 --- a/handlers/snow.go +++ b/handlers/snow.go @@ -49,4 +49,15 @@ func GetPlayer(c *fiber.Ctx) error { "displayName": person.DisplayName, "discord": person.Discord, }) +} + +func GetCachedPlayers(c *fiber.Ctx) error { + persons := p.AllFromCache() + players := make([]p.PersonSnapshot, len(persons)) + + for i, person := range persons { + players[i] = *person.Snapshot() + } + + return c.JSON(players) } \ No newline at end of file diff --git a/main.go b/main.go index 5db7156..37137a7 100644 --- a/main.go +++ b/main.go @@ -140,6 +140,7 @@ func main() { snow := r.Group("/snow") snow.Get("/sockets", handlers.GetConnectedSockets) + snow.Get("/cache", handlers.GetCachedPlayers) snow.Get("/cosmetics", handlers.GetPreloadedCosmetics) snow.Get("/image/:playlist", handlers.GetPlaylistImage)