Documentation ¶
Index ¶
- Constants
- func Close()
- func SetDefaultHttpClient(client *Xfasthttp)
- type Config
- type DataFlow
- func (df *DataFlow) AddHeader(h H) *DataFlow
- func (df *DataFlow) AddHeaderKV(key string, values ...string) *DataFlow
- func (df *DataFlow) AddQuery(key, value string) *DataFlow
- func (df *DataFlow) AddWWWForm(key string, values ...string) *DataFlow
- func (df *DataFlow) BindBytes(b *[]byte) *DataFlow
- func (df *DataFlow) BindFloat(f *float64) *DataFlow
- func (df *DataFlow) BindHeader(header H) *DataFlow
- func (df *DataFlow) BindInt(i *int) *DataFlow
- func (df *DataFlow) BindJson(obj interface{}) *DataFlow
- func (df *DataFlow) BindString(s *string) *DataFlow
- func (df *DataFlow) Degrade(f func() error) *DataFlow
- func (df *DataFlow) Do(ctx context.Context) (statusCode int, err error)
- func (df *DataFlow) SetBody(b []byte) *DataFlow
- func (df *DataFlow) SetContentType(t string) *DataFlow
- func (df *DataFlow) SetFormWithMap(data map[string]interface{}) *DataFlow
- func (df *DataFlow) SetJson(body interface{}) *DataFlow
- func (df *DataFlow) SetQuery(q Query) *DataFlow
- func (df *DataFlow) SetWWWForm(f WWWForm) *DataFlow
- func (df *DataFlow) Timeout(t time.Duration) *DataFlow
- func (df *DataFlow) WrapDoFunc(f func(DoFunc) DoFunc)
- type DoFunc
- type Duration
- type H
- type Query
- type WWWForm
- type Xfasthttp
Constants ¶
View Source
const ( HeaderKeyDowngrade = "X-Downgrade-Status" // 降级key HeaderValueDowngradeStatic = "STATIC" HeaderValueDowngradeDynamic = "DYNAMIC" HeaderKeyCircuitbreaking = "X-Envoy-Circuitbreaking" // 熔断 )
Variables ¶
This section is empty.
Functions ¶
func SetDefaultHttpClient ¶
func SetDefaultHttpClient(client *Xfasthttp)
Types ¶
type Config ¶
type Config struct { // User-Agent header,如果为空会设置默认header Name string // 如果为true,即使Name为空也不设置默认User-Agent NoDefaultUserAgentHeader bool // TLS配置,需要拆分 TLSConfig *tls.Config // 每个host的最大连接数 MaxConnsPerHost int // 空闲的keep-alive连接最大关闭时间 MaxIdleConnDuration time.Duration // keep-alive连接最大关闭时间 MaxConnDuration time.Duration // 最大重试次数 MaxIdemponentCallAttempts int // 每个连接的读缓存大小,会限制最大header长度 ReadBufferSize int // 每个连接的写缓存大小 WriteBufferSize int // 最大的回复读取时间 ReadTimeout time.Duration // 最大的写请求事件 WriteTimeout time.Duration // 最大的回复body大小 MaxResponseBodySize int // 等待空闲连接的最大时间。默认情况不等待,如果没有空闲连接返回ErrNoFreeConns错误。 MaxConnWaitTimeout time.Duration }
func DefaultConfig ¶
func DefaultConfig() *Config
type DataFlow ¶
type DataFlow struct { Err error // contains filtered or unexported fields }
DataFlow 是核心数据结构,用来保存http请求的中间状态数据,并负责发送请求和解析回复。
func (*DataFlow) AddHeaderKV ¶
AddHeaderKV 设置请求的http header
func (*DataFlow) AddWWWForm ¶
AddWWWForm 提供简便的x-www-form-urlencoded格式调用接口
func (*DataFlow) BindHeader ¶
func (*DataFlow) BindString ¶
BindString 将string值与body绑定
func (*DataFlow) SetContentType ¶
SetContentType 设置http header的ContentType
func (*DataFlow) SetFormWithMap ¶
func (*DataFlow) SetWWWForm ¶
SetWWWForm 设置请求体,格式是x-www-form-urlencoded
func (*DataFlow) WrapDoFunc ¶
Click to show internal directories.
Click to hide internal directories.