From 70c5f4f204fa5525f5ac99d27c3e3d3f9b6c8318 Mon Sep 17 00:00:00 2001 From: gaoshiyao Date: Thu, 7 Nov 2019 10:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B7=AF=E7=94=B1=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/proxy.yaml | 2 +- src/handler/proxyhandler.go | 12 ------------ src/main.go | 3 +++ src/router/router.go | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/docs/proxy.yaml b/docs/proxy.yaml index 9a1ed59..e798a6c 100644 --- a/docs/proxy.yaml +++ b/docs/proxy.yaml @@ -1,5 +1,5 @@ { - "uuid": "sdfasd", + "meshId": "sdfasd", "url":"https://apaas.wodcloud.com/cigservice/baseservice/fillder/turnover?applyId=0419f3e1-8e16-4e5e-a187-1760364c04e2", "method":"GET", "params":null diff --git a/src/handler/proxyhandler.go b/src/handler/proxyhandler.go index b2d57d6..f5ed5a6 100644 --- a/src/handler/proxyhandler.go +++ b/src/handler/proxyhandler.go @@ -34,19 +34,7 @@ func Proxy(c *gin.Context) { c.Error(err) return } - c.Writer.Write(result) - // - //req := c.Request - //baseUrl := "http://" + req.Host + req.URL.Path - //req.URL = testutils.ParseURI(getProxyURL(req)) - //req.RequestURI = getRequestURI(req) - //req.Host = req.URL.Host - //logrus.Info("************************************") - //logrus.Info("* 调用地址:", baseUrl) - //logrus.Info("* 转发地址:", req.URL) - //logrus.Info("************************************") - //fwd.ServeHTTP(c.Writer, req) } func getProxyURL(req *http.Request) string { diff --git a/src/main.go b/src/main.go index 79f5aef..0aab182 100644 --- a/src/main.go +++ b/src/main.go @@ -66,4 +66,7 @@ func getProxyConf() { } json.Unmarshal(b, &config.ProxyConf) fmt.Println("代理参数:", config.ProxyConf) + if len(config.ProxyConf.MeshId) > 0 { + *argPrefix += "/" + config.ProxyConf.MeshId + } } diff --git a/src/router/router.go b/src/router/router.go index 60aee0b..ca78d38 100644 --- a/src/router/router.go +++ b/src/router/router.go @@ -32,7 +32,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler { root := e.Group(config.Prefix) { root.GET("/count", handler.GetCount) - root.Any("/proxy/*action", handler.Proxy) + root.Any("/proxy", handler.Proxy) } return e -- 2.26.0