Documentation
¶
Overview ¶
Package client 持有签名 App API 的 HTTP transport 与公共请求处理。
Index ¶
- Constants
- func LoadOrCreateDeviceUUID(path string) (string, error)
- type AuthRequired
- type Client
- func (c *Client) CloseIdleConnections()
- func (c *Client) DeleteJSON(path string, params map[string]string, dest any) error
- func (c *Client) DeleteJSONContext(ctx context.Context, path string, params map[string]string, dest any) error
- func (c *Client) DeviceUUID() string
- func (c *Client) FetchMedia(rawURL string) ([]byte, error)
- func (c *Client) GetJSON(path string, params map[string]string, dest any) error
- func (c *Client) GetJSONContext(ctx context.Context, path string, params map[string]string, dest any) error
- func (c *Client) Language() string
- func (c *Client) PostFormJSON(path string, form map[string]string, dest any) error
- func (c *Client) PostFormJSONContext(ctx context.Context, path string, form map[string]string, dest any) error
- func (c *Client) SetLanguage(lang string)
- func (c *Client) SetToken(token string)
- func (c *Client) Token() string
- type Error
- type Options
Constants ¶
const ( AppVersion = model.AppVersion AppVersionNumber = model.AppVersionNumber UserAgent = model.UserAgent HostMirror = model.HostMirror HostMain = model.HostMain )
Variables ¶
This section is empty.
Functions ¶
func LoadOrCreateDeviceUUID ¶
LoadOrCreateDeviceUUID returns a stable device uuid from path, creating if missing.
Types ¶
type AuthRequired ¶
type AuthRequired = model.AuthRequired
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to /api/v1..v4 with jdsignature.
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
CloseIdleConnections 释放短生命周期 client 的空闲连接。
func (*Client) DeleteJSON ¶
DeleteJSON performs a signed DELETE.
func (*Client) DeleteJSONContext ¶
func (c *Client) DeleteJSONContext(ctx context.Context, path string, params map[string]string, dest any) error
DeleteJSONContext performs a signed DELETE with an explicit context.
func (*Client) DeviceUUID ¶
DeviceUUID returns the device id used in public params.
func (*Client) FetchMedia ¶
FetchMedia 获取未经过 App envelope 包装的媒体资源,供 media 包通过 callback 使用。
func (*Client) GetJSONContext ¶
func (c *Client) GetJSONContext(ctx context.Context, path string, params map[string]string, dest any) error
GetJSONContext performs a signed GET with an explicit context.
func (*Client) PostFormJSON ¶
PostFormJSON performs a signed POST form and unmarshals data.
func (*Client) PostFormJSONContext ¶
func (c *Client) PostFormJSONContext(ctx context.Context, path string, form map[string]string, dest any) error
PostFormJSONContext performs a signed POST form with an explicit context.
func (*Client) SetLanguage ¶
SetLanguage temporarily changes the language used by request headers.