http

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 12 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CredsFromClient added in v0.1.6

func CredsFromClient(c Client) *types.Credentials

CredsFromClient extracts Credentials from a Client when it implements the credentialedClient interface; returns nil otherwise.

func SetClient

func SetClient(c Client)

SetClient replaces the global SDK HTTP client.

func SetRateLimit added in v0.1.1

func SetRateLimit(enabled bool, perMinute int, burst int)

SetRateLimit configures the global per-route SDK request limiter. Passing enabled=false disables limiter waits while preserving GET merging.

func SetRateLimitEnabled added in v0.1.1

func SetRateLimitEnabled(enabled bool)

SetRateLimitEnabled toggles the global per-route SDK request limiter.

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

func ClientFor added in v0.1.6

func ClientFor(c Client) Client

ClientFor returns the per-call client when non-nil, otherwise the global client. Exported so callers outside the http package (e.g. file.Download) can resolve a per-call client with the same fallback semantics as Request.Do.

func GetClient

func GetClient() Client

GetClient returns the global SDK HTTP client, falling back to http.DefaultClient.

func OneOrNil added in v0.1.6

func OneOrNil(clients []Client) Client

OneOrNil returns the first element of a variadic Client slice, or nil. Used by file/user/auth functions to accept an optional per-call HTTP client.

type HTTPMethod

type HTTPMethod string
const (
	GET    HTTPMethod = "GET"
	POST   HTTPMethod = "POST"
	PUT    HTTPMethod = "PUT"
	DELETE HTTPMethod = "DELETE"
)

type PendingRequest added in v0.0.9

type PendingRequest struct {
	Response any // 用于缓存成功响应的结果
	// contains filtered or unexported fields
}

PendingRequest 用于保存正在进行的请求和等待结果的调用方

type Request

type Request[Req any, Res any] struct {
	BaseURL     string
	HTTPMethod  HTTPMethod
	Route       string
	Method      string
	AccessToken string
	Request     Req
	Response    Res
	HTTPClient  Client
	Credentials *types.Credentials
}

Request is the generic API-call builder. HTTPClient is optional; when nil the global client (GetClient) is used, allowing per-call client isolation. Credentials is optional; when non-nil it takes precedence over the package- level types.* globals for $-prefixed default resolution and AccessToken.

func (*Request[Req, Res]) Do

func (api *Request[Req, Res]) Do() (Res, error)

Jump to

Keyboard shortcuts

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