Documentation ¶
Index ¶
- Constants
- func Do(c Client, options RequestParams) (*http.Response, error)
- func DoAndDecodeJsonResponse(c Client, options RequestParams, ret interface{}) (*http.Response, error)
- func FormStringInfo(info map[string][]string) string
- func IsErrorRetryable(err error) bool
- func IsPrintRequest() bool
- func IsPrintRequestBody() bool
- func IsPrintRequestTrace() bool
- func IsPrintResponse() bool
- func IsPrintResponseBody() bool
- func NewRequest(options RequestParams) (*http.Request, error)
- func PrintRequest(level DebugLevel)
- func PrintRequestTrace(isPrint bool)
- func PrintResponse(level DebugLevel)
- type AuthConfig
- type Client
- type DebugLevel
- type Handler
- type HostsRetryConfig
- type Interceptor
- func NewAuthInterceptor(config AuthConfig) Interceptor
- func NewHostsRetryInterceptor(options HostsRetryConfig) Interceptor
- func NewSimpleInterceptor(...) Interceptor
- func NewSimpleInterceptorWithPriority(priority InterceptorPriority, ...) Interceptor
- func NewSimpleRetryInterceptor(config RetryConfig) Interceptor
- type InterceptorPriority
- type RequestBodyCreator
- type RequestParams
- type RetryConfig
Constants ¶
View Source
const ( RequestMethodGet = "GET" RequestMethodPut = "PUT" RequestMethodPost = "POST" RequestMethodHead = "HEAD" RequestMethodDelete = "DELETE" )
Variables ¶
This section is empty.
Functions ¶
func DoAndDecodeJsonResponse ¶
func DoAndDecodeJsonResponse(c Client, options RequestParams, ret interface{}) (*http.Response, error)
func FormStringInfo ¶
func IsErrorRetryable ¶
func IsPrintRequest ¶
func IsPrintRequest() bool
func IsPrintRequestBody ¶
func IsPrintRequestBody() bool
func IsPrintRequestTrace ¶
func IsPrintRequestTrace() bool
func IsPrintResponse ¶
func IsPrintResponse() bool
func IsPrintResponseBody ¶
func IsPrintResponseBody() bool
func NewRequest ¶
func NewRequest(options RequestParams) (*http.Request, error)
func PrintRequest ¶
func PrintRequest(level DebugLevel)
func PrintRequestTrace ¶
func PrintRequestTrace(isPrint bool)
func PrintResponse ¶
func PrintResponse(level DebugLevel)
Types ¶
type AuthConfig ¶
type AuthConfig struct { Credentials auth.Credentials // TokenType auth.TokenType // 不包含上传 }
type Client ¶
func NewClient ¶
func NewClient(cli Client, interceptors ...Interceptor) Client
func NewClientWithClientV1 ¶
type DebugLevel ¶
type DebugLevel int
const ( DebugLevelPrintNone DebugLevel = 0 DebugLevelPrintNormal DebugLevel = 1 DebugLevelPrintDetail DebugLevel = 2 )
type HostsRetryConfig ¶
type HostsRetryConfig struct { RetryConfig RetryConfig // 主备域名重试参数 HostFreezeDuration time.Duration // 主备域名冻结时间(默认:600s),当一个域名请求失败被冻结的时间,最小 time.Millisecond HostProvider hostprovider.HostProvider // 备用域名获取方法 ShouldFreezeHost func(req *http.Request, resp *http.Response, err error) bool }
type Interceptor ¶
type Interceptor interface { // Priority 数字越小优先级越高 Priority() InterceptorPriority // Intercept 拦截处理函数 Intercept(req *http.Request, handler Handler) (*http.Response, error) }
func NewAuthInterceptor ¶
func NewAuthInterceptor(config AuthConfig) Interceptor
func NewHostsRetryInterceptor ¶
func NewHostsRetryInterceptor(options HostsRetryConfig) Interceptor
func NewSimpleInterceptor ¶
func NewSimpleInterceptorWithPriority ¶
func NewSimpleInterceptorWithPriority(priority InterceptorPriority, interceptorHandler func(req *http.Request, handler Handler) (*http.Response, error)) Interceptor
func NewSimpleRetryInterceptor ¶
func NewSimpleRetryInterceptor(config RetryConfig) Interceptor
type InterceptorPriority ¶
type InterceptorPriority int
const ( InterceptorPriorityDefault InterceptorPriority = 100 InterceptorPriorityRetryHosts InterceptorPriority = 200 InterceptorPriorityRetrySimple InterceptorPriority = 300 InterceptorPrioritySetHeader InterceptorPriority = 400 InterceptorPriorityNormal InterceptorPriority = 500 InterceptorPriorityAuth InterceptorPriority = 600 InterceptorPriorityDebug InterceptorPriority = 700 )
type RequestBodyCreator ¶
type RequestBodyCreator func(options *RequestParams) (io.Reader, error)
func RequestBodyCreatorForm ¶
func RequestBodyCreatorForm(info map[string][]string) RequestBodyCreator
func RequestBodyCreatorOfJson ¶
func RequestBodyCreatorOfJson(object interface{}) RequestBodyCreator
type RequestParams ¶
Click to show internal directories.
Click to hide internal directories.