context

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//AccessTokenURL 获取access_token的接口
	AccessTokenURL = "https://api.weixin.qq.com/cgi-bin/token"
	//CacheKeyPrefix 微信公众号cache key前缀
	CacheKeyPrefix = "gowechat_officialaccount_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	*config.Config
	// contains filtered or unexported fields
}

Context struct

func (*Context) GetAccessToken

func (ctx *Context) GetAccessToken() (accessToken string, err error)

GetAccessToken 获取access_token

func (*Context) GetAccessTokenFromServer

func (ctx *Context) GetAccessTokenFromServer() (resAccessToken ResAccessToken, err error)

GetAccessTokenFromServer 强制从微信服务器获取token

func (*Context) GetJsAPITicketLock

func (ctx *Context) GetJsAPITicketLock() *sync.RWMutex

GetJsAPITicketLock 获取jsAPITicket 的lock

func (*Context) SetAccessTokenLock

func (ctx *Context) SetAccessTokenLock(l *sync.RWMutex)

SetAccessTokenLock 设置读写锁(一个appID一个读写锁)

func (*Context) SetGetAccessTokenFunc

func (ctx *Context) SetGetAccessTokenFunc(f GetAccessTokenFunc)

SetGetAccessTokenFunc 设置自定义获取accessToken的方式, 需要自己实现缓存

func (*Context) SetJsAPITicketLock

func (ctx *Context) SetJsAPITicketLock(lock *sync.RWMutex)

SetJsAPITicketLock 设置jsAPITicket的lock

type GetAccessTokenFunc

type GetAccessTokenFunc func(ctx *Context) (accessToken string, err error)

GetAccessTokenFunc 获取 access token 的函数签名

type ResAccessToken

type ResAccessToken struct {
	util.CommonError

	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

ResAccessToken struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL