mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 21:02:25 +08:00
add: 自定义获取 access token 方法
This commit is contained in:
@@ -22,7 +22,8 @@ type ResAccessToken struct {
|
||||
ExpiresIn int64 `json:"expires_in"`
|
||||
}
|
||||
|
||||
type CustomGetAccessToken func(ctx *Context) (accessToken string, err error)
|
||||
//GetAccessTokenFunc 获取 access token 的函数签名
|
||||
type GetAccessTokenFunc func(ctx *Context) (accessToken string, err error)
|
||||
|
||||
//SetAccessTokenLock 设置读写锁(一个appID一个读写锁)
|
||||
func (ctx *Context) SetAccessTokenLock(l *sync.RWMutex) {
|
||||
@@ -30,7 +31,7 @@ func (ctx *Context) SetAccessTokenLock(l *sync.RWMutex) {
|
||||
}
|
||||
|
||||
//SetGetAccessTokenFunc 设置自定义获取accessToken的方式, 需要自己实现缓存
|
||||
func (ctx *Context) SetGetAccessTokenFunc(f CustomGetAccessToken) {
|
||||
func (ctx *Context) SetGetAccessTokenFunc(f GetAccessTokenFunc) {
|
||||
ctx.accessTokenFunc = f
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ type Context struct {
|
||||
//jsAPITicket 读写锁 同一个AppID一个
|
||||
jsAPITicketLock *sync.RWMutex
|
||||
|
||||
//自定义获取 access token 的方法
|
||||
accessTokenFunc CustomGetAccessToken
|
||||
//accessTokenFunc 自定义获取 access token 的方法
|
||||
accessTokenFunc GetAccessTokenFunc
|
||||
}
|
||||
|
||||
// Query returns the keyed url query value if it exists
|
||||
|
||||
Reference in New Issue
Block a user