client

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package client 持有签名 App API 的 HTTP transport 与公共请求处理。

Index

Constants

View Source
const (
	AppVersion       = model.AppVersion
	AppVersionNumber = model.AppVersionNumber
	UserAgent        = model.UserAgent
	HostMirror       = model.HostMirror
	HostMain         = model.HostMain
)

Variables

This section is empty.

Functions

func LoadOrCreateDeviceUUID

func LoadOrCreateDeviceUUID(path string) (string, error)

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 New

func New(opts Options) (*Client, error)

New constructs a signed API client.

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

CloseIdleConnections 释放短生命周期 client 的空闲连接。

func (*Client) DeleteJSON

func (c *Client) DeleteJSON(path string, params map[string]string, dest any) error

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

func (c *Client) DeviceUUID() string

DeviceUUID returns the device id used in public params.

func (*Client) FetchMedia

func (c *Client) FetchMedia(rawURL string) ([]byte, error)

FetchMedia 获取未经过 App envelope 包装的媒体资源,供 media 包通过 callback 使用。

func (*Client) GetJSON

func (c *Client) GetJSON(path string, params map[string]string, dest any) error

GetJSON performs a signed GET and unmarshals data into dest (optional).

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) Language

func (c *Client) Language() string

Language returns the language used by request headers.

func (*Client) PostFormJSON

func (c *Client) PostFormJSON(path string, form map[string]string, dest any) error

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

func (c *Client) SetLanguage(lang string)

SetLanguage temporarily changes the language used by request headers.

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken updates the bearer token.

func (*Client) Token

func (c *Client) Token() string

Token returns the current bearer token.

type Error

type Error = model.Error

Error 和 AuthRequired 通过 alias 保持与 model 及公开 SDK 的类型身份一致。

type Options

type Options = model.Options

Options 是 model.Options 的兼容 alias。

Jump to

Keyboard shortcuts

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