From ffbdf4a8b0367c533d26777bd46103228428d597 Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Wed, 25 Dec 2024 18:49:47 +0800 Subject: [PATCH] feat(proxy): append proxy uri for apps --- main.go | 18 ++++++++++++++++-- src/miniProgram/application.go | 10 ++++++---- src/officialAccount/application.go | 10 ++++++---- src/payment/application.go | 10 ++++++---- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index 7cae36c3..17fd5daf 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,9 @@ func GetOfficialConfig() *officialAccount.UserConfig { Level: "debug", Stdout: false, }, + Http: officialAccount.Http{ + ProxyURI: "", + }, // ResponseType: os.Getenv("response_type"), Cache: kernel.NewRedisClient(&kernel.UniversalOptions{ @@ -57,6 +60,10 @@ func GetWorkConfig() *work.UserConfig { ENV: os.Getenv("work.env"), }, + Http: work.Http{ + ProxyURI: "", + }, + OAuth: work.OAuth{ Callback: os.Getenv("app_oauth_callback_url"), Scopes: []string{}, @@ -98,8 +105,9 @@ func GetPaymentConfig() *payment.UserConfig { Error: "./wechat/error.log", }, Http: payment.Http{ - Timeout: 30.0, - BaseURI: "https://api.mch.weixin.qq.com", + Timeout: 30.0, + BaseURI: "https://api.mch.weixin.qq.com", + ProxyURI: "", }, Cache: kernel.NewRedisClient(&kernel.UniversalOptions{ @@ -135,6 +143,9 @@ func GetMiniProgramConfig() *miniProgram.UserConfig { Password: "", DB: 1, }), + Http: miniProgram.Http{ + ProxyURI: "", + }, HttpDebug: true, //Debug: true, //"sandbox": true, @@ -159,6 +170,9 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig { Password: "", DB: 1, }), + Http: openPlatform.Http{ + ProxyURI: "", + }, // OAuth: "", // HttpDebug: "", // Debug: "", diff --git a/src/miniProgram/application.go b/src/miniProgram/application.go index 97156bcb..f972e632 100644 --- a/src/miniProgram/application.go +++ b/src/miniProgram/application.go @@ -127,8 +127,9 @@ type UserConfig struct { } type Http struct { - Timeout float64 - BaseURI string + Timeout float64 + BaseURI string + ProxyURI string } type Log struct { @@ -509,8 +510,9 @@ func MapUserConfig(userConfig *UserConfig) (*object.HashMap, error) { "response_type": userConfig.ResponseType, "http": &object.HashMap{ - "timeout": userConfig.Http.Timeout, - "base_uri": baseURI, + "timeout": userConfig.Http.Timeout, + "base_uri": baseURI, + "proxy_uri": userConfig.Http.ProxyURI, }, "log": &object.HashMap{ "driver": userConfig.Log.Driver, diff --git a/src/officialAccount/application.go b/src/officialAccount/application.go index 41367a9b..8fcf07f0 100644 --- a/src/officialAccount/application.go +++ b/src/officialAccount/application.go @@ -111,8 +111,9 @@ type UserConfig struct { } type Http struct { - Timeout float64 - BaseURI string + Timeout float64 + BaseURI string + ProxyURI string } type Log struct { @@ -457,8 +458,9 @@ func MapUserConfig(userConfig *UserConfig) (*object.HashMap, error) { "response_type": userConfig.ResponseType, "http": &object.HashMap{ - "timeout": timeout, - "base_uri": baseURI, + "timeout": timeout, + "base_uri": baseURI, + "proxy_uri": userConfig.Http.ProxyURI, }, "log": &object.HashMap{ "driver": userConfig.Log.Driver, diff --git a/src/payment/application.go b/src/payment/application.go index 8a89bfd8..cfd7f227 100644 --- a/src/payment/application.go +++ b/src/payment/application.go @@ -109,8 +109,9 @@ type OAuth struct { Scopes []string } type Http struct { - Timeout float64 - BaseURI string + Timeout float64 + BaseURI string + ProxyURI string } func NewPayment(config *UserConfig) (*Payment, error) { @@ -411,8 +412,9 @@ func MapUserConfig(userConfig *UserConfig) (*object.HashMap, error) { "stdout": userConfig.Log.Stdout, }, "http": &object.HashMap{ - "timeout": timeout, - "base_uri": baseURI, + "timeout": timeout, + "base_uri": baseURI, + "proxy_uri": userConfig.Http.ProxyURI, }, "oauth.callbacks": userConfig.OAuth.Callback, "oauth.scopes": userConfig.OAuth.Scopes,