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