Documentation ¶
Index ¶
- Variables
- func ParseTime(v string) (ret time.Time, err error)
- func SkipTokenRefresh(ctx context.Context) bool
- func With(ctx context.Context, v *Client) context.Context
- func WithSkipTokenRefresh(ctx context.Context, v bool) context.Context
- type Client
- func (c *Client) ApplyDefaultConfig()
- func (c *Client) Call(ctx context.Context, endpoint string, data url.Values) (ret gjson.Result, err error)
- func (c *Client) DecryptAPIResponse(r io.Reader) (ret io.Reader, err error)
- func (c *Client) EndpointURL(path string, values *url.Values) *url.URL
- func (c *Client) Login(ctx context.Context, username, password string) (ret gjson.Result, err error)
- func (c *Client) SetDefaultAPIAuthData(data url.Values)
- func (c *Client) SetDefaultHeader(key, value string)
- func (c *Client) SetRequestOptions(options ...RequestOption)
- type RequestOption
- type RequestOptionsTransport
- type TokenRefreshFunc
- type TokenRefresher
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = new(Client)
Default client
View Source
var DefaultAPIInitialVector []byte = getenvBase64("CIWEIMAO_API_INITIAL_VECTOR")
View Source
var DefaultAPIKey string = os.Getenv("CIWEIMAO_API_KEY")
View Source
var DefaultAccount string = os.Getenv("CIWEIMAO_ACCOUNT")
View Source
var DefaultAppVersion string = os.Getenv("CIWEIMAO_APP_VERSION")
View Source
var DefaultDeviceToken string = os.Getenv("CIWEIMAO_DEVICE_TOKEN")
View Source
var DefaultLoginToken string = os.Getenv("CIWEIMAO_LOGIN_TOKEN")
View Source
var DefaultPassword string = os.Getenv("CIWEIMAO_PASSWORD")
View Source
var DefaultServerURL string = os.Getenv("CIWEIMAO_SERVER_URL")
View Source
var DefaultUserAgent = os.Getenv("CIWEIMAO_USER_AGENT")
DefaultUserAgent for new clients
View Source
var DefaultUsername string = os.Getenv("CIWEIMAO_USERNAME")
Functions ¶
func SkipTokenRefresh ¶ added in v0.2.0
Types ¶
type Client ¶
type Client struct { APIInitialVector []byte APIKey string ServerURL string LoginToken string DeviceToken string Account string AppVersion string TokenRefresher TokenRefresher http.Client // contains filtered or unexported fields }
func (*Client) ApplyDefaultConfig ¶
func (c *Client) ApplyDefaultConfig()
func (*Client) DecryptAPIResponse ¶
func (*Client) EndpointURL ¶
EndpointURL returns url for server endpint.
func (*Client) SetDefaultAPIAuthData ¶
func (*Client) SetDefaultHeader ¶
SetDefaultHeader for all requests
func (*Client) SetRequestOptions ¶
func (c *Client) SetRequestOptions(options ...RequestOption)
SetRequestOptions for all requests
type RequestOption ¶
RequestOption can mutate request before actual send it.
type RequestOptionsTransport ¶
type RequestOptionsTransport struct {
// contains filtered or unexported fields
}
RequestOptionsTransport allow change request before do it.
type TokenRefreshFunc ¶ added in v0.2.0
func (TokenRefreshFunc) RefreshToken ¶ added in v0.2.0
func (fn TokenRefreshFunc) RefreshToken(ctx context.Context, c *Client) error
type TokenRefresher ¶ added in v0.2.0
TokenRefresher refresh login token on demand. use custom logic to store refreshed Client.LoginToken
func NewLoginTokenRefresher ¶ added in v0.2.0
func NewLoginTokenRefresher(username, password string) TokenRefresher
Click to show internal directories.
Click to hide internal directories.