From a92947dc01ea296b02f883b7828102590fff90f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=A8=E9=9B=AA?= Date: Mon, 17 Aug 2026 20:55:33 +0800 Subject: [PATCH] feat(p2): cluster remote nodes proxy GET /cluster/:id/nodes --- backend/internal/cluster/api.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/internal/cluster/api.go b/backend/internal/cluster/api.go index de1c28e..493645a 100644 --- a/backend/internal/cluster/api.go +++ b/backend/internal/cluster/api.go @@ -23,6 +23,7 @@ func (h *Handler) RegisterRoutes(rg *gin.RouterGroup) { rg.PUT("/:id", h.Update) rg.DELETE("/:id", h.Delete) rg.POST("/:id/health", h.Health) + rg.GET("/:id/nodes", h.RemoteNodes) } func parseID(c *gin.Context) (uint, bool) { @@ -107,3 +108,20 @@ func (h *Handler) Health(c *gin.Context) { } c.JSON(http.StatusOK, row) } + +func (h *Handler) RemoteNodes(c *gin.Context) { + id, ok := parseID(c) + if !ok { + return + } + raw, err := h.svc.FetchRemoteNodes(id) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + c.JSON(http.StatusNotFound, gin.H{"error": "not found"}) + return + } + c.JSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + c.Data(http.StatusOK, "application/json; charset=utf-8", raw) +}