Skip to content

Commit

Permalink
feat(proxy): append proxy uri for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Dec 25, 2024
1 parent 1be77cf commit ffbdf4a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
18 changes: 16 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{},
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -135,6 +143,9 @@ func GetMiniProgramConfig() *miniProgram.UserConfig {
Password: "",
DB: 1,
}),
Http: miniProgram.Http{
ProxyURI: "",
},
HttpDebug: true,
//Debug: true,
//"sandbox": true,
Expand All @@ -159,6 +170,9 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
Password: "",
DB: 1,
}),
Http: openPlatform.Http{
ProxyURI: "",
},
// OAuth: "",
// HttpDebug: "",
// Debug: "",
Expand Down
10 changes: 6 additions & 4 deletions src/miniProgram/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ type UserConfig struct {
}

type Http struct {
Timeout float64
BaseURI string
Timeout float64
BaseURI string
ProxyURI string
}

type Log struct {
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/officialAccount/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ type UserConfig struct {
}

type Http struct {
Timeout float64
BaseURI string
Timeout float64
BaseURI string
ProxyURI string
}

type Log struct {
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/payment/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ffbdf4a

Please sign in to comment.