From da5078826cb85bc0560139774f36232962588794 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 19 Nov 2024 16:22:49 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E9=BB=98=E8=AE=A4=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E8=B7=AF=E7=94=B1=20=E6=B2=BF=E7=94=A8=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E8=AF=B7=E6=B1=82=E8=B7=AF=E7=94=B1=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/configStruct.go | 4 ++-- configFiles/config_转发http2axy60000端口.json | 4 ++-- consumers/consumerHTTP_PRPXY.go | 10 +++++++--- dbHelper/apiServerHelper.go | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config/configStruct.go b/config/configStruct.go index f6ccdf4..b8a4fc8 100644 --- a/config/configStruct.go +++ b/config/configStruct.go @@ -40,8 +40,8 @@ type HttpConfig struct { } type ApiServerConfig struct { - Port uint `json:"port"` - Routes map[string]string `json:"routes"` + Port uint `json:"port"` + Routers map[string]string `json:"routers"` } type Token struct { diff --git a/configFiles/config_转发http2axy60000端口.json b/configFiles/config_转发http2axy60000端口.json index 5b35c55..b9e8c1f 100644 --- a/configFiles/config_转发http2axy60000端口.json +++ b/configFiles/config_转发http2axy60000端口.json @@ -6,7 +6,7 @@ "port": 7000, "userName": "anQuanDai", "password": "123", - "routes": { + "routers": { "route1": "POST /upload/work/ABStatus", "route2": "POST /upload/work/ABHeart" } @@ -14,7 +14,7 @@ }, "out": { "httpPost": { - "url": "http://218.3.126.49:60000/upload", + "url": "http://218.3.126.49:60000", "method": "post" } } diff --git a/consumers/consumerHTTP_PRPXY.go b/consumers/consumerHTTP_PRPXY.go index 5636d24..fd477a2 100644 --- a/consumers/consumerHTTP_PRPXY.go +++ b/consumers/consumerHTTP_PRPXY.go @@ -44,7 +44,7 @@ func (the *consumerHttpProxy) InputInitial() error { //数据入口 the.InApiServer = dbHelper.NewApiServer( the.Info.IoConfig.In.ApiServer.Port, - the.Info.IoConfig.In.ApiServer.Routes, + the.Info.IoConfig.In.ApiServer.Routers, ) the.InApiServer.Initial() return nil @@ -59,9 +59,11 @@ func (the *consumerHttpProxy) OutputInitial() error { } func (the *consumerHttpProxy) Work() { go func() { - router := "POST /onData" - the.InApiServer.RouteRegister(router, the.onData) + for _, router := range the.Info.IoConfig.In.ApiServer.Routers { + the.InApiServer.RouteRegister(router, the.onData) + } the.InApiServer.Run() + }() } func (the *consumerHttpProxy) onData(w http.ResponseWriter, r *http.Request) { @@ -86,6 +88,8 @@ func (the *consumerHttpProxy) onData(w http.ResponseWriter, r *http.Request) { params := map[string]string{ "id": id, } + //沿用请求路由 + the.outHttpPost.Url += r.URL.String() resp, err := the.outHttpPost.HttpPostWithParams(string(body), params) if err != nil { return diff --git a/dbHelper/apiServerHelper.go b/dbHelper/apiServerHelper.go index 29a98a0..ba9c167 100644 --- a/dbHelper/apiServerHelper.go +++ b/dbHelper/apiServerHelper.go @@ -30,7 +30,7 @@ func (the *ApiServerHelper) Initial() { Addr: fmt.Sprintf(":%d", the.port), } - the.routeRegister() + //the.routeRegister() } func (the *ApiServerHelper) Run() {