Documentation ¶
Index ¶
- Variables
- type Accept
- type ContentType
- type ContentTypeStruct
- type HttpClient
- func (r *HttpClient) AddHeaders(headers map[string][]string) *HttpClient
- func (r *HttpClient) GenerateRequest() *HttpClient
- func (r *HttpClient) GetRequest() *http.Request
- func (r *HttpClient) GetResponse() *http.Response
- func (r *HttpClient) GetResponseJsonBody(target any) *HttpClient
- func (r *HttpClient) GetResponseRawBody() []byte
- func (r *HttpClient) GetResponseXmlBody(target any) *HttpClient
- func (r *HttpClient) ParseByContentType(target any) *HttpClient
- func (r *HttpClient) SaveResponseSteamFile(filename string) *HttpClient
- func (r *HttpClient) Send() *HttpClient
- func (r *HttpClient) SetAuthorization(username, password, title string) *HttpClient
- func (r *HttpClient) SetBody(body []byte) *HttpClient
- func (r *HttpClient) SetCert(filename string) *HttpClient
- func (r *HttpClient) SetCssBody(text string) *HttpClient
- func (r *HttpClient) SetFormBody(body map[string]string) *HttpClient
- func (r *HttpClient) SetFormDataBody(texts map[string]string, files map[string]string) *HttpClient
- func (r *HttpClient) SetHeaderAccept(key string) *HttpClient
- func (r *HttpClient) SetHeaderContentType(key string) *HttpClient
- func (r *HttpClient) SetHtmlBody(text string) *HttpClient
- func (r *HttpClient) SetJavascriptBody(text string) *HttpClient
- func (r *HttpClient) SetJsonBody(body any) *HttpClient
- func (r *HttpClient) SetMethod(method string) *HttpClient
- func (r *HttpClient) SetPlainBody(text string) *HttpClient
- func (r *HttpClient) SetQueries(queries map[string]string) *HttpClient
- func (r *HttpClient) SetSteamBody(filename string) *HttpClient
- func (r *HttpClient) SetTimeoutSecond(timeoutSecond int64) *HttpClient
- func (r *HttpClient) SetUrl(url string) *HttpClient
- func (r *HttpClient) SetXmlBody(body any) *HttpClient
- type HttpClientContentType
- type HttpClientMultiple
- func (receiver *HttpClientMultiple) Add(hc *HttpClient) *HttpClientMultiple
- func (receiver *HttpClientMultiple) GetClients() []*HttpClient
- func (HttpClientMultiple) New() *HttpClientMultiple
- func (receiver *HttpClientMultiple) Send() *HttpClientMultiple
- func (receiver *HttpClientMultiple) SetClients(clients []*HttpClient) *HttpClientMultiple
Constants ¶
This section is empty.
Variables ¶
var ( ContentTypeJson HttpClientContentType = "json" ContentTypeXml HttpClientContentType = "xml" ContentTypeForm HttpClientContentType = "form" ContentTypeFormData HttpClientContentType = "form-data" ContentTypePlain HttpClientContentType = "plain" ContentTypeHtml HttpClientContentType = "html" ContentTypeCss HttpClientContentType = "css" ContentTypeJavascript HttpClientContentType = "javascript" ContentTypeSteam HttpClientContentType = "steam" AcceptJson httpClientAccept = "json" AcceptXml httpClientAccept = "xml" AcceptPlain httpClientAccept = "plain" AcceptHtml httpClientAccept = "html" AcceptCss httpClientAccept = "css" AcceptJavascript httpClientAccept = "javascript" AcceptSteam httpClientAccept = "steam" AcceptAny httpClientAccept = "any" )
Functions ¶
This section is empty.
Types ¶
type Accept ¶
type Accept struct {
ContentTypeStruct
}
type ContentTypeStruct ¶
type HttpClient ¶
type HttpClient struct { Err error // contains filtered or unexported fields }
HttpClient http客户端
func (*HttpClient) AddHeaders ¶
func (r *HttpClient) AddHeaders(headers map[string][]string) *HttpClient
AddHeaders 设置请求头
func (*HttpClient) GenerateRequest ¶
func (r *HttpClient) GenerateRequest() *HttpClient
GenerateRequest 生成请求对象
func (*HttpClient) GetResponse ¶
func (r *HttpClient) GetResponse() *http.Response
GetResponse 获取响应对象
func (*HttpClient) GetResponseJsonBody ¶
func (r *HttpClient) GetResponseJsonBody(target any) *HttpClient
GetResponseJsonBody 获取json格式响应体
func (*HttpClient) GetResponseRawBody ¶
func (r *HttpClient) GetResponseRawBody() []byte
GetResponseRawBody 获取原始响应体
func (*HttpClient) GetResponseXmlBody ¶
func (r *HttpClient) GetResponseXmlBody(target any) *HttpClient
GetResponseXmlBody 获取xml格式响应体
func (*HttpClient) ParseByContentType ¶
func (r *HttpClient) ParseByContentType(target any) *HttpClient
ParseByContentType 根据响应头Content-Type自动解析响应体
func (*HttpClient) SaveResponseSteamFile ¶
func (r *HttpClient) SaveResponseSteamFile(filename string) *HttpClient
SaveResponseSteamFile 保存二进制到文件
func (*HttpClient) SetAuthorization ¶
func (r *HttpClient) SetAuthorization(username, password, title string) *HttpClient
SetAuthorization 设置认证
func (*HttpClient) SetCert ¶
func (r *HttpClient) SetCert(filename string) *HttpClient
SetCert 设置SSL证书
func (*HttpClient) SetCssBody ¶
func (r *HttpClient) SetCssBody(text string) *HttpClient
SetCssBody 设置Css请求体
func (*HttpClient) SetFormBody ¶
func (r *HttpClient) SetFormBody(body map[string]string) *HttpClient
SetFormBody 设置表单请求体
func (*HttpClient) SetFormDataBody ¶
func (r *HttpClient) SetFormDataBody(texts map[string]string, files map[string]string) *HttpClient
SetFormDataBody 设置表单数据请求体
func (*HttpClient) SetHeaderAccept ¶
func (r *HttpClient) SetHeaderAccept(key string) *HttpClient
SetHeaderAccept 设置请求头接受内容类型
func (*HttpClient) SetHeaderContentType ¶
func (r *HttpClient) SetHeaderContentType(key string) *HttpClient
SetHeaderContentType 设置请求头内容类型
func (*HttpClient) SetHtmlBody ¶
func (r *HttpClient) SetHtmlBody(text string) *HttpClient
SetHtmlBody 设置html请求体
func (*HttpClient) SetJavascriptBody ¶
func (r *HttpClient) SetJavascriptBody(text string) *HttpClient
SetJavascriptBody 设置Javascript请求体
func (*HttpClient) SetJsonBody ¶
func (r *HttpClient) SetJsonBody(body any) *HttpClient
SetJsonBody 设置json请求体
func (*HttpClient) SetMethod ¶
func (r *HttpClient) SetMethod(method string) *HttpClient
SetMethod 设置请求方法
func (*HttpClient) SetPlainBody ¶
func (r *HttpClient) SetPlainBody(text string) *HttpClient
SetPlainBody 设置纯文本请求体
func (*HttpClient) SetQueries ¶
func (r *HttpClient) SetQueries(queries map[string]string) *HttpClient
SetQueries 设置请求参数
func (*HttpClient) SetSteamBody ¶
func (r *HttpClient) SetSteamBody(filename string) *HttpClient
SetSteamBody 设置二进制文件
func (*HttpClient) SetTimeoutSecond ¶
func (r *HttpClient) SetTimeoutSecond(timeoutSecond int64) *HttpClient
SetTimeoutSecond 设置超时
func (*HttpClient) SetXmlBody ¶
func (r *HttpClient) SetXmlBody(body any) *HttpClient
SetXmlBody 设置xml请求体
type HttpClientContentType ¶
type HttpClientContentType = string
type HttpClientMultiple ¶
type HttpClientMultiple struct {
// contains filtered or unexported fields
}
func (*HttpClientMultiple) Add ¶
func (receiver *HttpClientMultiple) Add(hc *HttpClient) *HttpClientMultiple
Add 添加httpClient对象
func (*HttpClientMultiple) GetClients ¶
func (receiver *HttpClientMultiple) GetClients() []*HttpClient
GetClients 获取链接池
func (HttpClientMultiple) New ¶
func (HttpClientMultiple) New() *HttpClientMultiple
New New 实例化:批量请求对象
func (*HttpClientMultiple) Send ¶
func (receiver *HttpClientMultiple) Send() *HttpClientMultiple
Send 批量发送
func (*HttpClientMultiple) SetClients ¶
func (receiver *HttpClientMultiple) SetClients(clients []*HttpClient) *HttpClientMultiple
SetClients 设置httpClient对象