Documentation
¶
Index ¶
- Variables
- type Accept
- type ContentType
- type GenerateCertError
- type GenerateRequestError
- type HttpClient
- func (my *HttpClient) AddHeaders(headers map[string][]string) *HttpClient
- func (my *HttpClient) AppendHeaderAccept(keys ...Accept) *HttpClient
- func (my *HttpClient) AppendHeaderContentType(keys ...ContentType) *HttpClient
- func (my *HttpClient) Download(filename string) *HttpClientDownload
- func (my *HttpClient) GenerateRequest() *HttpClient
- func (my *HttpClient) GetRequest() *http.Request
- func (my *HttpClient) GetResponse() *http.Response
- func (my *HttpClient) GetResponseJsonBody(target any, keys ...any) *HttpClient
- func (my *HttpClient) GetResponseRawBody() []byte
- func (my *HttpClient) GetResponseXmlBody(target any) *HttpClient
- func (*HttpClient) New(url string) *HttpClient
- func (*HttpClient) NewDelete(url string) *HttpClient
- func (*HttpClient) NewGet(url string) *HttpClient
- func (*HttpClient) NewPost(url string) *HttpClient
- func (*HttpClient) NewPut(url string) *HttpClient
- func (my *HttpClient) ParseByContentType(target any) *HttpClient
- func (my *HttpClient) SaveResponseSteamFile(filename string) *HttpClient
- func (my *HttpClient) Send() *HttpClient
- func (my *HttpClient) SetAuthorization(username, password, title string) *HttpClient
- func (my *HttpClient) SetBody(body []byte) *HttpClient
- func (my *HttpClient) SetCert(filename string) *HttpClient
- func (my *HttpClient) SetCssBody(text string) *HttpClient
- func (my *HttpClient) SetFormBody(body map[string]string) *HttpClient
- func (my *HttpClient) SetFormDataBody(texts map[string]string, files map[string]string) *HttpClient
- func (my *HttpClient) SetHeaderAccept(key Accept) *HttpClient
- func (my *HttpClient) SetHeaderContentType(key ContentType) *HttpClient
- func (my *HttpClient) SetHeaders(headers map[string][]string) *HttpClient
- func (my *HttpClient) SetHtmlBody(text string) *HttpClient
- func (my *HttpClient) SetJavascriptBody(text string) *HttpClient
- func (my *HttpClient) SetJsonBody(body any) *HttpClient
- func (my *HttpClient) SetMethod(method string) *HttpClient
- func (my *HttpClient) SetPlainBody(text string) *HttpClient
- func (my *HttpClient) SetQueries(queries map[string]string) *HttpClient
- func (my *HttpClient) SetSteamBody(filename string) *HttpClient
- func (my *HttpClient) SetTimeoutSecond(timeoutSecond int64) *HttpClient
- func (my *HttpClient) SetUrl(url string) *HttpClient
- func (my *HttpClient) SetXmlBody(body any) *HttpClient
- type HttpClientDownload
- func (*HttpClientDownload) New(httpClient *HttpClient, filename string) *HttpClientDownload
- func (my *HttpClientDownload) SaveLocal() *HttpClient
- func (my *HttpClientDownload) SendResponse(w http.ResponseWriter, headers map[string][]string) *HttpClient
- func (my *HttpClientDownload) SetProcessContent(processContent string) *HttpClientDownload
- type Multiple
- type ReadResponseError
- type SetFormBodyError
- type SetJsonBodyError
- type SetSteamBodyError
- type SetXmlBodyError
- type UnmarshalJsonError
- type UnmarshalXmlError
- type UrlEmptyError
- type WriteResponseError
Constants ¶
This section is empty.
Variables ¶
var ( ReadResponseErr ReadResponseError UrlEmptyErr UrlEmptyError GenerateCertErr GenerateCertError GenerateRequestErr GenerateRequestError UnmarshalXmlErr UnmarshalXmlError UnmarshalJsonErr UnmarshalJsonError SetSteamBodyErr SetSteamBodyError SetFormBodyErr SetFormBodyError SetXmlBodyErr SetXmlBodyError SetJsonBodyErr SetJsonBodyError WriteResponseErr WriteResponseError )
var ( ContentTypeJson ContentType = "json" ContentTypeXml ContentType = "xml" ContentTypeForm ContentType = "form" ContentTypeFormData ContentType = "form-data" ContentTypePlain ContentType = "plain" ContentTypeHtml ContentType = "html" ContentTypeCss ContentType = "css" ContentTypeJavascript ContentType = "javascript" ContentTypeSteam ContentType = "steam" ContentTypes = map[ContentType]string{ ContentTypeJson: "application/json", ContentTypeXml: "application/xml", ContentTypeForm: "application/x-www-form-urlencoded", ContentTypeFormData: "form-data", ContentTypePlain: "text/plain", ContentTypeHtml: "text/html", ContentTypeCss: "text/css", ContentTypeJavascript: "text/javascript", ContentTypeSteam: "application/octet-stream", } AcceptJson Accept = "json" AcceptXml Accept = "xml" AcceptPlain Accept = "plain" AcceptHtml Accept = "html" AcceptCss Accept = "css" AcceptJavascript Accept = "javascript" AcceptSteam Accept = "steam" AcceptAny Accept = "any" Accepts = map[Accept]string{ AcceptJson: "application/json", AcceptXml: "application/xml", AcceptPlain: "text/plain", AcceptHtml: "text/html", AcceptCss: "text/css", AcceptJavascript: "text/javascript", AcceptSteam: "application/octet-stream", AcceptAny: "*/*", } )
Functions ¶
This section is empty.
Types ¶
type ContentType ¶
type ContentType string
type GenerateCertError ¶
func (*GenerateCertError) Error ¶
func (my *GenerateCertError) Error() string
func (*GenerateCertError) Is ¶
func (my *GenerateCertError) Is(target error) bool
func (*GenerateCertError) Panic ¶
func (*GenerateCertError) Panic() myError.IMyError
type GenerateRequestError ¶
func (*GenerateRequestError) Error ¶
func (my *GenerateRequestError) Error() string
func (*GenerateRequestError) Is ¶
func (my *GenerateRequestError) Is(target error) bool
func (*GenerateRequestError) Panic ¶
func (*GenerateRequestError) Panic() myError.IMyError
type HttpClient ¶
type HttpClient struct { Err error // contains filtered or unexported fields }
HttpClient http客户端
var App HttpClient
func (*HttpClient) AddHeaders ¶
func (my *HttpClient) AddHeaders(headers map[string][]string) *HttpClient
AddHeaders 追加请求头
func (*HttpClient) AppendHeaderAccept ¶
func (my *HttpClient) AppendHeaderAccept(keys ...Accept) *HttpClient
AppendHeaderAccept 追加请求头接受内容类型
func (*HttpClient) AppendHeaderContentType ¶
func (my *HttpClient) AppendHeaderContentType(keys ...ContentType) *HttpClient
AppendHeaderContentType 追加请求头内容类型
func (*HttpClient) Download ¶
func (my *HttpClient) Download(filename string) *HttpClientDownload
Download 使用下载器下载文件
func (*HttpClient) GenerateRequest ¶
func (my *HttpClient) GenerateRequest() *HttpClient
GenerateRequest 生成请求对象
func (*HttpClient) GetResponse ¶
func (my *HttpClient) GetResponse() *http.Response
GetResponse 获取响应对象
func (*HttpClient) GetResponseJsonBody ¶
func (my *HttpClient) GetResponseJsonBody(target any, keys ...any) *HttpClient
GetResponseJsonBody 获取json格式响应体
func (*HttpClient) GetResponseRawBody ¶
func (my *HttpClient) GetResponseRawBody() []byte
GetResponseRawBody 获取原始响应体
func (*HttpClient) GetResponseXmlBody ¶
func (my *HttpClient) GetResponseXmlBody(target any) *HttpClient
GetResponseXmlBody 获取xml格式响应体
func (*HttpClient) New ¶
func (*HttpClient) New(url string) *HttpClient
func (*HttpClient) NewDelete ¶
func (*HttpClient) NewDelete(url string) *HttpClient
func (*HttpClient) NewGet ¶
func (*HttpClient) NewGet(url string) *HttpClient
func (*HttpClient) NewPost ¶
func (*HttpClient) NewPost(url string) *HttpClient
func (*HttpClient) NewPut ¶
func (*HttpClient) NewPut(url string) *HttpClient
func (*HttpClient) ParseByContentType ¶
func (my *HttpClient) ParseByContentType(target any) *HttpClient
ParseByContentType 根据响应头Content-Type自动解析响应体
func (*HttpClient) SaveResponseSteamFile ¶
func (my *HttpClient) SaveResponseSteamFile(filename string) *HttpClient
SaveResponseSteamFile 保存二进制到文件
func (*HttpClient) SetAuthorization ¶
func (my *HttpClient) SetAuthorization(username, password, title string) *HttpClient
SetAuthorization 设置认证
func (*HttpClient) SetCert ¶
func (my *HttpClient) SetCert(filename string) *HttpClient
SetCert 设置SSL证书
func (*HttpClient) SetCssBody ¶
func (my *HttpClient) SetCssBody(text string) *HttpClient
SetCssBody 设置Css请求体
func (*HttpClient) SetFormBody ¶
func (my *HttpClient) SetFormBody(body map[string]string) *HttpClient
SetFormBody 设置表单请求体
func (*HttpClient) SetFormDataBody ¶
func (my *HttpClient) SetFormDataBody(texts map[string]string, files map[string]string) *HttpClient
SetFormDataBody 设置表单数据请求体
func (*HttpClient) SetHeaderAccept ¶
func (my *HttpClient) SetHeaderAccept(key Accept) *HttpClient
SetHeaderAccept 设置请求头接受内容类型
func (*HttpClient) SetHeaderContentType ¶
func (my *HttpClient) SetHeaderContentType(key ContentType) *HttpClient
SetHeaderContentType 设置请求头内容类型
func (*HttpClient) SetHeaders ¶
func (my *HttpClient) SetHeaders(headers map[string][]string) *HttpClient
SetHeaders 设置请求头
func (*HttpClient) SetHtmlBody ¶
func (my *HttpClient) SetHtmlBody(text string) *HttpClient
SetHtmlBody 设置html请求体
func (*HttpClient) SetJavascriptBody ¶
func (my *HttpClient) SetJavascriptBody(text string) *HttpClient
SetJavascriptBody 设置Javascript请求体
func (*HttpClient) SetJsonBody ¶
func (my *HttpClient) SetJsonBody(body any) *HttpClient
SetJsonBody 设置json请求体
func (*HttpClient) SetMethod ¶
func (my *HttpClient) SetMethod(method string) *HttpClient
SetMethod 设置请求方法
func (*HttpClient) SetPlainBody ¶
func (my *HttpClient) SetPlainBody(text string) *HttpClient
SetPlainBody 设置纯文本请求体
func (*HttpClient) SetQueries ¶
func (my *HttpClient) SetQueries(queries map[string]string) *HttpClient
SetQueries 设置请求参数
func (*HttpClient) SetSteamBody ¶
func (my *HttpClient) SetSteamBody(filename string) *HttpClient
SetSteamBody 设置二进制文件
func (*HttpClient) SetTimeoutSecond ¶
func (my *HttpClient) SetTimeoutSecond(timeoutSecond int64) *HttpClient
SetTimeoutSecond 设置超时
func (*HttpClient) SetXmlBody ¶
func (my *HttpClient) SetXmlBody(body any) *HttpClient
SetXmlBody 设置xml请求体
type HttpClientDownload ¶
type HttpClientDownload struct {
// contains filtered or unexported fields
}
var HttpClientDownloadApp HttpClientDownload
func (*HttpClientDownload) New ¶
func (*HttpClientDownload) New(httpClient *HttpClient, filename string) *HttpClientDownload
New 实例化http客户端下载器
func (*HttpClientDownload) SaveLocal ¶
func (my *HttpClientDownload) SaveLocal() *HttpClient
Save 保存到本地
func (*HttpClientDownload) SendResponse ¶
func (my *HttpClientDownload) SendResponse(w http.ResponseWriter, headers map[string][]string) *HttpClient
Send 发送到客户端
func (*HttpClientDownload) SetProcessContent ¶
func (my *HttpClientDownload) SetProcessContent(processContent string) *HttpClientDownload
SetProcessContent 设置终端进度条标题
type Multiple ¶
type Multiple struct {
// contains filtered or unexported fields
}
var MultipleApp Multiple
func (*Multiple) Append ¶
func (my *Multiple) Append(hc *HttpClient) *Multiple
Append 添加httpClient对象
func (*Multiple) SetClients ¶
func (my *Multiple) SetClients(clients []*HttpClient) *Multiple
SetClients 设置httpClient对象
type ReadResponseError ¶
func (*ReadResponseError) Error ¶
func (my *ReadResponseError) Error() string
func (*ReadResponseError) Is ¶
func (my *ReadResponseError) Is(target error) bool
func (*ReadResponseError) Panic ¶
func (*ReadResponseError) Panic() myError.IMyError
type SetFormBodyError ¶
func (*SetFormBodyError) Error ¶
func (my *SetFormBodyError) Error() string
func (*SetFormBodyError) Is ¶
func (my *SetFormBodyError) Is(target error) bool
func (*SetFormBodyError) Panic ¶
func (*SetFormBodyError) Panic() myError.IMyError
type SetJsonBodyError ¶
func (*SetJsonBodyError) Error ¶
func (my *SetJsonBodyError) Error() string
func (*SetJsonBodyError) Is ¶
func (my *SetJsonBodyError) Is(target error) bool
func (*SetJsonBodyError) Panic ¶
func (*SetJsonBodyError) Panic() myError.IMyError
type SetSteamBodyError ¶
func (*SetSteamBodyError) Error ¶
func (my *SetSteamBodyError) Error() string
func (*SetSteamBodyError) Is ¶
func (my *SetSteamBodyError) Is(target error) bool
func (*SetSteamBodyError) Panic ¶
func (*SetSteamBodyError) Panic() myError.IMyError
type SetXmlBodyError ¶
func (*SetXmlBodyError) Error ¶
func (my *SetXmlBodyError) Error() string
func (*SetXmlBodyError) Is ¶
func (my *SetXmlBodyError) Is(target error) bool
func (*SetXmlBodyError) Panic ¶
func (*SetXmlBodyError) Panic() myError.IMyError
type UnmarshalJsonError ¶
func (*UnmarshalJsonError) Error ¶
func (my *UnmarshalJsonError) Error() string
func (*UnmarshalJsonError) Is ¶
func (my *UnmarshalJsonError) Is(target error) bool
func (*UnmarshalJsonError) Panic ¶
func (*UnmarshalJsonError) Panic() myError.IMyError
type UnmarshalXmlError ¶
func (*UnmarshalXmlError) Error ¶
func (my *UnmarshalXmlError) Error() string
func (*UnmarshalXmlError) Is ¶
func (my *UnmarshalXmlError) Is(target error) bool
func (*UnmarshalXmlError) Panic ¶
func (*UnmarshalXmlError) Panic() myError.IMyError
type UrlEmptyError ¶
func (*UrlEmptyError) Error ¶
func (my *UrlEmptyError) Error() string
func (*UrlEmptyError) Is ¶
func (my *UrlEmptyError) Is(target error) bool
func (*UrlEmptyError) Panic ¶
func (*UrlEmptyError) Panic() myError.IMyError
type WriteResponseError ¶
func (*WriteResponseError) Error ¶
func (my *WriteResponseError) Error() string
func (*WriteResponseError) Is ¶
func (my *WriteResponseError) Is(target error) bool
func (*WriteResponseError) Panic ¶
func (*WriteResponseError) Panic() myError.IMyError