From 949c7815622c8729c18fee651377b7d990f43979 Mon Sep 17 00:00:00 2001 From: liugq Date: Thu, 24 Feb 2022 17:12:40 +0800 Subject: [PATCH] update gateway instance api --- plugin/api/gateway/instance.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin/api/gateway/instance.go b/plugin/api/gateway/instance.go index 71611f3f..619da931 100644 --- a/plugin/api/gateway/instance.go +++ b/plugin/api/gateway/instance.go @@ -214,14 +214,24 @@ func (h *GatewayAPI) getInstanceStatus(w http.ResponseWriter, req *http.Request, password = "" } gid, _ := instance.GetValue("id") - connRes, err := h.doConnect(endpoint.(string), gateway.BasicAuth{ - Username: username.(string), - Password: password.(string), + res, err := doGatewayRequest(&ProxyRequest{ + Endpoint: endpoint.(string), + Method: http.MethodGet, + Path: "/stats", + BasicAuth: gateway.BasicAuth{ + Username: username.(string), + Password: password.(string), + }, }) if err != nil { log.Error(err) + result[gid.(string)] = util.MapStr{} + continue } - result[gid.(string)] = connRes + var resMap = util.MapStr{} + util.MustFromJSONBytes(res.Body, &resMap) + + result[gid.(string)] = resMap } h.WriteJSON(w, result, http.StatusOK) }