Documentation ¶
Index ¶
- Variables
- type ClientHttp
- func (c *ClientHttp) ContentType(value string) *ClientHttp
- func (c *ClientHttp) DisableKeepAlives() *ClientHttp
- func (c *ClientHttp) Error() error
- func (c *ClientHttp) FormParams(obj map[string]interface{}) *ClientHttp
- func (c *ClientHttp) Header(key, value string) *ClientHttp
- func (c *ClientHttp) HeaderSet(key, value string) *ClientHttp
- func (c *ClientHttp) RequestHeader() http.Header
- func (c *ClientHttp) ResetParam() *ClientHttp
- func (c *ClientHttp) RunGet(clientUrl string) (clientResp *ClientResp, err error)
- func (c *ClientHttp) RunPatch(clientUrl string) (clientResp *ClientResp, err error)
- func (c *ClientHttp) RunPost(clientUrl string) (clientResp *ClientResp, err error)
- func (c *ClientHttp) RunPut(clientUrl string) (clientResp *ClientResp, err error)
- func (c *ClientHttp) RunRequest(method, clientUrl string) (clientResp *ClientResp, err error)
- func (c *ClientHttp) SetBasicAuth(username, password string) *ClientHttp
- func (c *ClientHttp) SetCookies(cookies []*http.Cookie) *ClientHttp
- func (c *ClientHttp) SetTimeout(timeout int) *ClientHttp
- func (c *ClientHttp) SkipHttps() *ClientHttp
- func (c *ClientHttp) WithBody(bodyStream string) *ClientHttp
- func (c *ClientHttp) WithCookie() *ClientHttp
- func (c *ClientHttp) WithFile(name string, filePath string) *ClientHttp
- func (c *ClientHttp) WithFormRequest() *ClientHttp
- func (c *ClientHttp) WithHost(host string) *ClientHttp
- func (c *ClientHttp) WithJsonBody(data interface{}) *ClientHttp
- func (c *ClientHttp) WithJsonRequest() *ClientHttp
- type ClientResp
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }
Functions ¶
This section is empty.
Types ¶
type ClientHttp ¶
type ClientHttp struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient() *ClientHttp
func (*ClientHttp) ContentType ¶
func (c *ClientHttp) ContentType(value string) *ClientHttp
func (*ClientHttp) DisableKeepAlives ¶ added in v0.2.23
func (c *ClientHttp) DisableKeepAlives() *ClientHttp
DisableKeepAlives 关闭KeepAlives
func (*ClientHttp) Error ¶
func (c *ClientHttp) Error() error
func (*ClientHttp) FormParams ¶
func (c *ClientHttp) FormParams(obj map[string]interface{}) *ClientHttp
参数设置 表单请求支持json和form两种类型
func (*ClientHttp) Header ¶
func (c *ClientHttp) Header(key, value string) *ClientHttp
Header 原样保持header头大小写设置
func (*ClientHttp) HeaderSet ¶ added in v0.2.24
func (c *ClientHttp) HeaderSet(key, value string) *ClientHttp
HeaderSet 自动校正header头格式
func (*ClientHttp) RequestHeader ¶ added in v0.4.0
func (c *ClientHttp) RequestHeader() http.Header
HeaderSet 自动校正header头格式
func (*ClientHttp) RunGet ¶
func (c *ClientHttp) RunGet(clientUrl string) (clientResp *ClientResp, err error)
RunGet 执行Get请求
func (*ClientHttp) RunPatch ¶ added in v0.3.3
func (c *ClientHttp) RunPatch(clientUrl string) (clientResp *ClientResp, err error)
func (*ClientHttp) RunPost ¶
func (c *ClientHttp) RunPost(clientUrl string) (clientResp *ClientResp, err error)
func (*ClientHttp) RunPut ¶ added in v0.3.3
func (c *ClientHttp) RunPut(clientUrl string) (clientResp *ClientResp, err error)
func (*ClientHttp) RunRequest ¶ added in v0.3.3
func (c *ClientHttp) RunRequest(method, clientUrl string) (clientResp *ClientResp, err error)
RunGet 执行Post请求
func (*ClientHttp) SetBasicAuth ¶ added in v0.5.17
func (c *ClientHttp) SetBasicAuth(username, password string) *ClientHttp
SetBasicAuth 添加 basic auth 认证
func (*ClientHttp) SetCookies ¶ added in v0.4.0
func (c *ClientHttp) SetCookies(cookies []*http.Cookie) *ClientHttp
func (*ClientHttp) SetTimeout ¶
func (c *ClientHttp) SetTimeout(timeout int) *ClientHttp
func (*ClientHttp) SkipHttps ¶ added in v0.2.17
func (c *ClientHttp) SkipHttps() *ClientHttp
SkipHttps 跳过https证书校验
func (*ClientHttp) WithBody ¶
func (c *ClientHttp) WithBody(bodyStream string) *ClientHttp
直接传递body中的参数
func (*ClientHttp) WithCookie ¶
func (c *ClientHttp) WithCookie() *ClientHttp
cookie保持 通过配置请求id将cookie保持
func (*ClientHttp) WithFile ¶ added in v0.2.28
func (c *ClientHttp) WithFile(name string, filePath string) *ClientHttp
WithFile 添加文件form-data方式发送
func (*ClientHttp) WithFormRequest ¶
func (c *ClientHttp) WithFormRequest() *ClientHttp
WithFormRequest 快速配置表单请求类型
func (*ClientHttp) WithHost ¶ added in v0.2.16
func (c *ClientHttp) WithHost(host string) *ClientHttp
WithHost 添加请求头host
func (*ClientHttp) WithJsonBody ¶ added in v0.3.3
func (c *ClientHttp) WithJsonBody(data interface{}) *ClientHttp
将结构体或任意结构转成json作为参数
func (*ClientHttp) WithJsonRequest ¶
func (c *ClientHttp) WithJsonRequest() *ClientHttp
WithFormRequest 快速配置表单请求类型
type ClientResp ¶
type ClientResp struct { Body []byte // response body BodyRaw *http.Response RequestTime time.Duration CookieData map[string]*http.Cookie }
func (*ClientResp) GetRequestTime ¶
func (c *ClientResp) GetRequestTime() time.Duration
func (*ClientResp) String ¶
func (c *ClientResp) String() string
Click to show internal directories.
Click to hide internal directories.