client

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(ctx context.Context, rawURL string) (io.ReadCloser, error)

FetchMedia 获取未经过 App envelope 包装的媒体资源,供 media 包通过 callback 使用。 ctx 贯穿媒体请求,取消时立即中断网络读取。成功时由调用方负责关闭返回的 body; transport 不把媒体响应一次性读入内存,由上层按用途流式消费。

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