Skip to content

Commit

Permalink
Merge pull request #27 from bbhj/master
Browse files Browse the repository at this point in the history
Support Wechat.Set() function
  • Loading branch information
esap authored Feb 17, 2020
2 parents 5c9a3da + b03e9f7 commit 85d2f79
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ type Server struct {
ExternalTokenHandler func(appId string, appName ...string) *AccessToken // 通过外部方法统一获取access token ,避免集群情况下token失效
}

func Set(wc *WxConfig) *Server {
return &Server{
AppId: wc.AppId,
Secret: wc.Secret,
AgentId: wc.AgentId,
MchId: wc.MchId,
AppName: wc.AppName,
AppType: wc.AppType,
Token: wc.Token,
EncodingAESKey: wc.EncodingAESKey,
ExternalTokenHandler: wc.ExternalTokenHandler,
}
}
// New 微信服务容器
func New(wc *WxConfig) *Server {
s := &Server{
AppId: wc.AppId,
Secret: wc.Secret,
AgentId: wc.AgentId,
MchId: wc.MchId,
AppName: wc.AppName,
AppType: wc.AppType,
Token: wc.Token,
EncodingAESKey: wc.EncodingAESKey,
ExternalTokenHandler: wc.ExternalTokenHandler,
}
s := Set(wc)

switch wc.AppType {
case 1:
Expand Down

0 comments on commit 85d2f79

Please sign in to comment.