Documentation ¶
Index ¶
- Constants
- func Close()
- func SetDefaultHttpClient(client *HttpClient)
- 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) CircuitBreaker(resource string, f func() error) *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 FastHeaderCarrier
- type H
- type HttpClient
- type Option
- type Query
- type WWWForm
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 *HttpClient)
Types ¶
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) CircuitBreaker ¶
func (*DataFlow) SetContentType ¶
SetContentType 设置http header的ContentType
func (*DataFlow) SetFormWithMap ¶
func (*DataFlow) SetWWWForm ¶
SetWWWForm 设置请求体,格式是x-www-form-urlencoded
func (*DataFlow) WrapDoFunc ¶
type Duration ¶
func (*Duration) UnmarshalText ¶
type FastHeaderCarrier ¶
func NewFastHeaderCarrier ¶
func NewFastHeaderCarrier(req *fasthttp.Request) *FastHeaderCarrier
func (FastHeaderCarrier) Get ¶
func (fhc FastHeaderCarrier) Get(key string) string
func (FastHeaderCarrier) Keys ¶
func (fhc FastHeaderCarrier) Keys() []string
func (FastHeaderCarrier) Set ¶
func (fhc FastHeaderCarrier) Set(key string, value string)
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func Default ¶
func Default() *HttpClient
func DefaultHttpClient ¶
func DefaultHttpClient() *HttpClient
func (*HttpClient) Close ¶
func (c *HttpClient) Close()
func (*HttpClient) Delete ¶
func (c *HttpClient) Delete(url string) *DataFlow
Delete 调用http客户端的DELETE方法
type Option ¶
type Option 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 // EnableTracer bool }
func DefaultOption ¶
func DefaultOption() *Option
Click to show internal directories.
Click to hide internal directories.