Documentation ¶
Index ¶
- Variables
- func DefaultBucketHosts() region.Endpoints
- func WithoutSignature(ctx context.Context) context.Context
- type BasicHTTPClient
- type Client
- func (httpClient *Client) AccelerateUploadingEnabled() bool
- func (httpClient *Client) Do(ctx context.Context, request *Request) (*http.Response, error)
- func (httpClient *Client) DoAndAcceptJSON(ctx context.Context, request *Request, ret interface{}) error
- func (httpClient *Client) GetAfterBackoffCallback() func(*http.Request, *retrier.RetrierOptions, time.Duration)
- func (httpClient *Client) GetAfterResolveCallback() func(*http.Request, []net.IP)
- func (httpClient *Client) GetAfterResponseCallback() func(*http.Response, *retrier.RetrierOptions, error)
- func (httpClient *Client) GetAfterSignCallback() func(*http.Request)
- func (httpClient *Client) GetAllRegions() region.RegionsProvider
- func (httpClient *Client) GetBeforeBackoffCallback() func(*http.Request, *retrier.RetrierOptions, time.Duration)
- func (httpClient *Client) GetBeforeRequestCallback() func(*http.Request, *retrier.RetrierOptions)
- func (httpClient *Client) GetBeforeResolveCallback() func(*http.Request)
- func (httpClient *Client) GetBeforeSignCallback() func(*http.Request)
- func (httpClient *Client) GetBucketQuery() region.BucketRegionsQuery
- func (httpClient *Client) GetChooser() chooser.Chooser
- func (httpClient *Client) GetClient() BasicHTTPClient
- func (httpClient *Client) GetCredentials() credentials.CredentialsProvider
- func (httpClient *Client) GetHostFreezeDuration() time.Duration
- func (httpClient *Client) GetHostRetryConfig() *RetryConfig
- func (httpClient *Client) GetHostsRetryConfig() *RetryConfig
- func (httpClient *Client) GetRegions() region.RegionsProvider
- func (httpClient *Client) GetResolveErrorCallback() func(*http.Request, error)
- func (httpClient *Client) GetResolver() resolver.Resolver
- func (httpClient *Client) GetSignErrorCallback() func(*http.Request, error)
- func (httpClient *Client) UseInsecureProtocol() bool
- type GetRequestBody
- type Handler
- type Interceptor
- type InterceptorPriority
- type MultipartForm
- type MultipartFormBinaryData
- type Options
- type Request
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoRegion = errors.New("no region from provider") ErrNoEndpointsConfigured = errors.New("no endpoints configured") )
Functions ¶
func DefaultBucketHosts ¶
DefaultBucketHosts 默认的 Bucket 域名列表
Types ¶
type BasicHTTPClient ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 提供了对七牛 HTTP 客户端
func (*Client) AccelerateUploadingEnabled ¶ added in v7.23.0
func (*Client) DoAndAcceptJSON ¶
func (httpClient *Client) DoAndAcceptJSON(ctx context.Context, request *Request, ret interface{}) error
DoAndAcceptJSON 发送 HTTP 请求并接收 JSON 响应
func (*Client) GetAfterBackoffCallback ¶ added in v7.22.0
func (*Client) GetAfterResolveCallback ¶ added in v7.22.0
func (*Client) GetAfterResponseCallback ¶ added in v7.22.0
func (*Client) GetAfterSignCallback ¶ added in v7.23.0
func (*Client) GetAllRegions ¶ added in v7.23.0
func (httpClient *Client) GetAllRegions() region.RegionsProvider
func (*Client) GetBeforeBackoffCallback ¶ added in v7.22.0
func (*Client) GetBeforeRequestCallback ¶ added in v7.22.0
func (httpClient *Client) GetBeforeRequestCallback() func(*http.Request, *retrier.RetrierOptions)
func (*Client) GetBeforeResolveCallback ¶ added in v7.22.0
func (*Client) GetBeforeSignCallback ¶ added in v7.23.0
func (*Client) GetBucketQuery ¶
func (httpClient *Client) GetBucketQuery() region.BucketRegionsQuery
func (*Client) GetChooser ¶ added in v7.22.0
func (*Client) GetClient ¶
func (httpClient *Client) GetClient() BasicHTTPClient
func (*Client) GetCredentials ¶
func (httpClient *Client) GetCredentials() credentials.CredentialsProvider
func (*Client) GetHostFreezeDuration ¶
func (*Client) GetHostRetryConfig ¶
func (httpClient *Client) GetHostRetryConfig() *RetryConfig
func (*Client) GetHostsRetryConfig ¶
func (httpClient *Client) GetHostsRetryConfig() *RetryConfig
func (*Client) GetRegions ¶
func (httpClient *Client) GetRegions() region.RegionsProvider
func (*Client) GetResolveErrorCallback ¶ added in v7.22.0
func (*Client) GetResolver ¶ added in v7.22.0
func (*Client) GetSignErrorCallback ¶ added in v7.23.0
func (*Client) UseInsecureProtocol ¶
type GetRequestBody ¶
type GetRequestBody = clientv2.GetRequestBody
func GetFormRequestBody ¶
func GetFormRequestBody(info map[string][]string) GetRequestBody
GetFormRequestBody 将数据通过 Form 作为请求 Body 发送
func GetJsonRequestBody ¶
func GetJsonRequestBody(object interface{}) (GetRequestBody, error)
GetJsonRequestBody 将数据通过 JSON 作为请求 Body 发送
func GetMultipartFormRequestBody ¶
func GetMultipartFormRequestBody(info *MultipartForm) GetRequestBody
GetMultipartFormRequestBody 将数据通过 Multipart 表单作为请求 Body 发送
func GetRequestBodyFromReadSeekCloser ¶
func GetRequestBodyFromReadSeekCloser(r compatible_io.ReadSeekCloser) GetRequestBody
GetMultipartFormRequestBody 将二进制数据请求 Body 发送
type Interceptor ¶
type Interceptor = clientv2.Interceptor
type InterceptorPriority ¶
type InterceptorPriority = clientv2.InterceptorPriority
type MultipartFormBinaryData ¶
type MultipartFormBinaryData struct { Data compatible_io.ReadSeekCloser Name string ContentType string }
type Options ¶
type Options struct { // 基础 HTTP 客户端 BasicHTTPClient BasicHTTPClient // 空间区域查询器 BucketQuery region.BucketRegionsQuery // 所有区域提供者 AllRegions region.RegionsProvider // 区域提供者 Regions region.RegionsProvider // 凭证信息提供者 Credentials credentials.CredentialsProvider // 拦截器 Interceptors []Interceptor // 是否使用 HTTP 协议 UseInsecureProtocol bool // 域名解析器 Resolver resolver.Resolver // 域名选择器 Chooser chooser.Chooser // 单域名重试配置 HostRetryConfig *RetryConfig // 主备域名重试配置 HostsRetryConfig *RetryConfig // 主备域名冻结时间 HostFreezeDuration time.Duration // 主备域名冻结判断函数 ShouldFreezeHost func(*http.Request, *http.Response, error) bool // 签名前回调函数 BeforeSign func(*http.Request) // 签名后回调函数 AfterSign func(*http.Request) // 签名错误回调函数 SignError func(*http.Request, error) // 域名解析前回调函数 BeforeResolve func(*http.Request) // 域名解析后回调函数 AfterResolve func(*http.Request, []net.IP) // 域名解析错误回调函数 ResolveError func(*http.Request, error) // 退避前回调函数 BeforeBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration) // 退避后回调函数 AfterBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration) // 请求前回调函数 BeforeRequest func(*http.Request, *retrier.RetrierOptions) // 请求后回调函数 AfterResponse func(*http.Response, *retrier.RetrierOptions, error) // 是否加速上传 AccelerateUploading bool }
Options 为构建 Client 提供了可选参数
type Request ¶
type Request struct { // 请求方法 Method string // 请求服务名 ServiceNames []region.ServiceName // 服务地址提供者 Endpoints region.EndpointsProvider // 区域提供者 Region region.RegionsProvider // 请求路径 Path string // 原始请求查询参数 RawQuery string // 请求查询参数 Query url.Values // 请求头 Header http.Header // 请求 Body 获取函数 RequestBody GetRequestBody // 凭证信息提供者 Credentials credentials.CredentialsProvider // 授权类型 AuthType auth.TokenType // 上传凭证接口 UpToken uptoken.UpTokenProvider // 是否缓存响应 BufferResponse bool // 拦截器追加列表 Interceptors []Interceptor // 请求进度回调函数 OnRequestProgress func(uint64, uint64) }
Request 包含一个具体的 HTTP 请求的参数
type RetryConfig ¶
type RetryConfig = clientv2.RetryConfig
Click to show internal directories.
Click to hide internal directories.