Skip to content

Commit 85d2f79

Browse files
authored
Merge pull request #27 from bbhj/master
Support Wechat.Set() function
2 parents 5c9a3da + b03e9f7 commit 85d2f79

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

server.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,22 @@ type Server struct {
8787
ExternalTokenHandler func(appId string, appName ...string) *AccessToken // 通过外部方法统一获取access token ,避免集群情况下token失效
8888
}
8989

90+
func Set(wc *WxConfig) *Server {
91+
return &Server{
92+
AppId: wc.AppId,
93+
Secret: wc.Secret,
94+
AgentId: wc.AgentId,
95+
MchId: wc.MchId,
96+
AppName: wc.AppName,
97+
AppType: wc.AppType,
98+
Token: wc.Token,
99+
EncodingAESKey: wc.EncodingAESKey,
100+
ExternalTokenHandler: wc.ExternalTokenHandler,
101+
}
102+
}
90103
// New 微信服务容器
91104
func New(wc *WxConfig) *Server {
92-
s := &Server{
93-
AppId: wc.AppId,
94-
Secret: wc.Secret,
95-
AgentId: wc.AgentId,
96-
MchId: wc.MchId,
97-
AppName: wc.AppName,
98-
AppType: wc.AppType,
99-
Token: wc.Token,
100-
EncodingAESKey: wc.EncodingAESKey,
101-
ExternalTokenHandler: wc.ExternalTokenHandler,
102-
}
105+
s := Set(wc)
103106

104107
switch wc.AppType {
105108
case 1:

0 commit comments

Comments
 (0)