Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Code2Session(code string) (*Code2SessionResult, error)
- func (c *Client) Get(url string, obj interface{}) ([]byte, error)
- func (c *Client) GetAccessToken() (string, error)
- func (c *Client) GetCachePrefix() string
- func (c *Client) HasQuery(url string) bool
- func (c *Client) Post(url string, body []byte, obj interface{}, header map[string]string) ([]byte, error)
- func (c *Client) PostJSON(url string, params interface{}, obj interface{}) ([]byte, error)
- func (c *Client) RefreshAccessToken() (string, error)
- type Code2SessionResult
- type GetAccessTokenResult
- type HttpCliOptions
- type HttpClient
- type Options
- type RedisStore
- func (r *RedisStore) GetAccessToken(key string) (string, error)
- func (r *RedisStore) GetJsapiTicket(key string) (string, error)
- func (r *RedisStore) SetAccessToken(key string, accessToken string, expires int64) error
- func (r *RedisStore) SetJsapiTicket(key string, jsapiTicket string, expires int64) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ObjDecodeErr 返回值对象解析错误 ObjDecodeErr = web.NewErrorModel(-1, "json解析失败", nil, http.StatusBadRequest) // StructNotHasCommonError 请求需要解析的对象错误 没有commonError StructNotHasCommonError = web.NewErrorModel(-1, "需要解析的结构体错误", nil, http.StatusBadRequest) )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { HttpClient interfaces.HttpClient Store interfaces.Store AppId string `json:"app_id" yaml:"app_id"` AppSecret string `json:"app_secret" yaml:"app_secret"` CachePrefix string `json:"cache_prefix" yaml:"cache_prefix"` AccessToken string `json:"access_token" yaml:"access_token"` AccessTokenLock *sync.Mutex // contains filtered or unexported fields }
func (*Client) Code2Session ¶
func (c *Client) Code2Session(code string) (*Code2SessionResult, error)
Code2Session 登陆凭证校验的结果
func (*Client) GetAccessToken ¶
GetAccessToken 获取access_token
func (*Client) RefreshAccessToken ¶
RefreshAccessToken 刷新access_token
type Code2SessionResult ¶
type Code2SessionResult struct { response.CommonError OpenId string `json:"openid"` SessionKey string `json:"session_key"` UnionId string `json:"unionid"` }
Code2SessionResult 获取用户的openid和session_key 的结果
type GetAccessTokenResult ¶
type GetAccessTokenResult struct { response.CommonError AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
GetAccessTokenResult 获取access_token结果
type HttpCliOptions ¶
type HttpCliOptions func(*HttpClient)
func WithHttpClientCtx ¶
func WithHttpClientCtx(c context.Context) HttpCliOptions
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(opts ...HttpCliOptions) *HttpClient
type Options ¶
type Options func(*Client)
func WithAccessToken ¶
func WithAppidAndSecret ¶
func WithCachePrefix ¶
func WithHttpClient ¶
func WithHttpClient(cli interfaces.HttpClient) Options
func WithRedisStore ¶
func WithRedisStore(cli *redis.Client) Options
type RedisStore ¶
type RedisStore struct { Client *redis.Client // contains filtered or unexported fields }
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) *RedisStore
func (*RedisStore) GetAccessToken ¶
func (r *RedisStore) GetAccessToken(key string) (string, error)
func (*RedisStore) GetJsapiTicket ¶ added in v0.0.7
func (r *RedisStore) GetJsapiTicket(key string) (string, error)
func (*RedisStore) SetAccessToken ¶
func (r *RedisStore) SetAccessToken(key string, accessToken string, expires int64) error
func (*RedisStore) SetJsapiTicket ¶ added in v0.0.7
func (r *RedisStore) SetJsapiTicket(key string, jsapiTicket string, expires int64) error
Click to show internal directories.
Click to hide internal directories.