Documentation
¶
Index ¶
- Variables
- type AccessTokenType
- type Client
- func (c *Client) Get(url string, obj interface{}) ([]byte, error)
- func (c *Client) GetAccessToken() (string, error)
- func (c *Client) GetCachePrefix() string
- func (c *Client) GetJsapiTicket() (string, error)
- 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 GetAccessTokenResult
- type HttpCliOptions
- type HttpClient
- type JsapiTicketResponse
- 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 AccessTokenType ¶
type AccessTokenType string
const ( // ContactAccessTokenType 通讯录 ContactAccessTokenType AccessTokenType = "contact_secret" // ExternalContactAccessTokenType 外部联系人 ExternalContactAccessTokenType AccessTokenType = "external_contact_secret" )
type Client ¶
type Client struct { CorpID string `json:"corp_id"` CorpSecret string `json:"corp_secret"` CachePrefix string `json:"cache_prefix" yaml:"cache_prefix"` AccessToken string `json:"access_token" yaml:"access_token"` AccessTokenLock *sync.Mutex HttpClient interfaces.HttpClient Store interfaces.Store Debug bool // contains filtered or unexported fields }
func (*Client) GetAccessToken ¶
GetAccessToken 获取access_token
func (*Client) GetJsapiTicket ¶ added in v0.0.7
GetJsapiTicket 获取企业的jsapi_ticket
func (*Client) RefreshAccessToken ¶
RefreshAccessToken 刷新access_token
type GetAccessTokenResult ¶
type GetAccessTokenResult struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` 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
func WithHttpClientDebug ¶ added in v0.0.7
func WithHttpClientDebug(debug bool) HttpCliOptions
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(opts ...HttpCliOptions) *HttpClient
type JsapiTicketResponse ¶ added in v0.0.7
type Options ¶
type Options func(*Client)
func WithAccessToken ¶
func WithAppidAndSecret ¶
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.