-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
支持使用代理访问微信接口 #556
base: v2
Are you sure you want to change the base?
支持使用代理访问微信接口 #556
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一点小修改,另外ci的错误修正一下
client := req.C() | ||
if proxyUrl != "" { | ||
client.SetProxyURL(proxyUrl) | ||
} | ||
resp, err := client.R().Get(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分可以直接封装在util.HTTPGetWithProxy
方法中
@@ -124,7 +127,7 @@ func (ak *WorkAccessToken) GetAccessToken() (accessToken string, err error) { | |||
|
|||
// cache失效,从微信服务器获取 | |||
var resAccessToken ResAccessToken | |||
resAccessToken, err = GetTokenFromServer(fmt.Sprintf(workAccessTokenURL, ak.CorpID, ak.CorpSecret)) | |||
resAccessToken, err = GetTokenFromServer(fmt.Sprintf(workAccessTokenURL, ak.CorpID, ak.CorpSecret), ak.cacheKeyPrefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不是传入ak.cacheKeyPrefix
吧
package core | ||
|
||
import ( | ||
"github.com/imroc/req/v3" | ||
"github.com/silenceper/wechat/v2/cache" | ||
) | ||
|
||
// Config .config for 微信公众号 | ||
type Config struct { | ||
AppID string `json:"app_id"` // appid | ||
AppSecret string `json:"app_secret"` // appsecret | ||
ProxyUrl string `json:"proxy_url"` // 代理url | ||
Cache cache.Cache | ||
} | ||
|
||
func (c *Config) Req() *req.Request { | ||
client := req.C() | ||
if c.ProxyUrl != "" { | ||
client.SetProxyURL(c.ProxyUrl) | ||
} | ||
return client.R() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个core我理解是抽象公共的配置字段吧,是ok的
目前只有ProxyUrl
,Cache
两个字段是公共的
这 刚需啊 不让merge 进去 ? |
统一管理大量公众号时候就可以不用配置白名单,对管理大量公众号很有用