From e7c4dc58b71802ce73b09dfb62c72752d42464cc Mon Sep 17 00:00:00 2001 From: Gardel Date: Thu, 5 Jun 2025 02:25:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=85=AC=E9=92=A5?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/home_router.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/router/home_router.go b/router/home_router.go index 599d40d..b0636cb 100644 --- a/router/home_router.go +++ b/router/home_router.go @@ -62,8 +62,9 @@ type HomeRouter interface { } type homeRouterImpl struct { - serverMeta ServerMeta - myPubKey KeyPair + serverMeta ServerMeta + myPubKey KeyPair + cachedPubKey *PublicKeys } func NewHomeRouter(meta *ServerMeta) HomeRouter { @@ -81,6 +82,10 @@ func (h *homeRouterImpl) Home(c *gin.Context) { } func (h *homeRouterImpl) PublicKeys(c *gin.Context) { + if h.cachedPubKey != nil { + c.JSON(http.StatusOK, h.cachedPubKey) + return + } publicKeys := PublicKeys{} err := util.GetObject("https://api.minecraftservices.com/publickeys", &publicKeys) if err != nil { @@ -90,4 +95,5 @@ func (h *homeRouterImpl) PublicKeys(c *gin.Context) { publicKeys.ProfilePropertyKeys = append(publicKeys.ProfilePropertyKeys, h.myPubKey) publicKeys.PlayerCertificateKeys = append(publicKeys.PlayerCertificateKeys, h.myPubKey) c.JSON(http.StatusOK, publicKeys) + h.cachedPubKey = &publicKeys }