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) SetSteamBodyByFile(filename string) *HttpClient
- func (my *HttpClient) SetSteamBodyByReader(reader io.ReadCloser) *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 ¶ added in v1.10.10
func (*GenerateCertError) Error ¶ added in v1.10.10
func (my *GenerateCertError) Error() string
func (*GenerateCertError) Is ¶ added in v1.10.10
func (my *GenerateCertError) Is(target error) bool
func (*GenerateCertError) New ¶ added in v1.10.10
func (*GenerateCertError) New(msg string) myError.IMyError
func (*GenerateCertError) Panic ¶ added in v1.10.24
func (*GenerateCertError) Panic() myError.IMyError
type GenerateRequestError ¶ added in v1.10.10
func (*GenerateRequestError) Error ¶ added in v1.10.10
func (my *GenerateRequestError) Error() string
func (*GenerateRequestError) Is ¶ added in v1.10.10
func (my *GenerateRequestError) Is(target error) bool
func (*GenerateRequestError) New ¶ added in v1.10.10
func (*GenerateRequestError) New(msg string) myError.IMyError
func (*GenerateRequestError) Panic ¶ added in v1.10.24
func (*GenerateRequestError) Panic() myError.IMyError
type HttpClient ¶
type HttpClient struct { Err error // contains filtered or unexported fields }
HttpClient http客户端
var App HttpClient
func NewHttpClient ¶ added in v1.0.16
func NewHttpClient(url string) *HttpClient
NewHttpClient 实例化:http客户端
func (*HttpClient) AddHeaders ¶
func (my *HttpClient) AddHeaders(headers map[string][]string) *HttpClient
AddHeaders 追加请求头
func (*HttpClient) AppendHeaderAccept ¶ added in v1.7.10
func (my *HttpClient) AppendHeaderAccept(keys ...Accept) *HttpClient
AppendHeaderAccept 追加请求头接受内容类型
func (*HttpClient) AppendHeaderContentType ¶ added in v1.7.10
func (my *HttpClient) AppendHeaderContentType(keys ...ContentType) *HttpClient
AppendHeaderContentType 追加请求头内容类型
func (*HttpClient) Download ¶ added in v1.7.10
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 ¶ added in v1.7.10
func (*HttpClient) New(url string) *HttpClient
func (*HttpClient) NewDelete ¶ added in v1.9.10
func (*HttpClient) NewDelete(url string) *HttpClient
func (*HttpClient) NewGet ¶ added in v1.9.10
func (*HttpClient) NewGet(url string) *HttpClient
func (*HttpClient) NewPost ¶ added in v1.9.10
func (*HttpClient) NewPost(url string) *HttpClient
func (*HttpClient) NewPut ¶ added in v1.9.10
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 ¶ added in v1.9.11
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) SetSteamBodyByFile ¶ added in v1.20.3
func (my *HttpClient) SetSteamBodyByFile(filename string) *HttpClient
SetSteamBodyByFile 设置字节码内容:通过文件
func (*HttpClient) SetSteamBodyByReader ¶ added in v1.20.3
func (my *HttpClient) SetSteamBodyByReader(reader io.ReadCloser) *HttpClient
SetSteamBodyByReader 设置字节码内容:通过readCloser接口
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 ¶ added in v1.10.9
type HttpClientDownload struct {
// contains filtered or unexported fields
}
var HttpClientDownloadApp HttpClientDownload
func (*HttpClientDownload) New ¶ added in v1.10.9
func (*HttpClientDownload) New(httpClient *HttpClient, filename string) *HttpClientDownload
New 实例化http客户端下载器
func (*HttpClientDownload) SaveLocal ¶ added in v1.10.10
func (my *HttpClientDownload) SaveLocal() *HttpClient
SaveLocal 保存到本地
func (*HttpClientDownload) SendResponse ¶ added in v1.10.10
func (my *HttpClientDownload) SendResponse(w http.ResponseWriter, headers map[string][]string) *HttpClient
SendResponse 发送到客户端
func (*HttpClientDownload) SetProcessContent ¶ added in v1.10.9
func (my *HttpClientDownload) SetProcessContent(processContent string) *HttpClientDownload
SetProcessContent 设置终端进度条标题
type Multiple ¶ added in v1.0.16
type Multiple struct {
// contains filtered or unexported fields
}
var MultipleApp Multiple
func (*Multiple) Append ¶ added in v1.9.26
func (my *Multiple) Append(hc *HttpClient) *Multiple
Append 添加httpClient对象
func (*Multiple) GetClients ¶ added in v1.0.16
func (my *Multiple) GetClients() []*HttpClient
GetClients 获取链接池
func (*Multiple) SetClients ¶ added in v1.0.16
func (my *Multiple) SetClients(clients []*HttpClient) *Multiple
SetClients 设置httpClient对象
type ReadResponseError ¶ added in v1.10.10
func (*ReadResponseError) Error ¶ added in v1.10.10
func (my *ReadResponseError) Error() string
func (*ReadResponseError) Is ¶ added in v1.10.10
func (my *ReadResponseError) Is(target error) bool
func (*ReadResponseError) New ¶ added in v1.10.10
func (*ReadResponseError) New(msg string) myError.IMyError
func (*ReadResponseError) Panic ¶ added in v1.10.24
func (*ReadResponseError) Panic() myError.IMyError
type SetFormBodyError ¶ added in v1.10.10
func (*SetFormBodyError) Error ¶ added in v1.10.10
func (my *SetFormBodyError) Error() string
func (*SetFormBodyError) Is ¶ added in v1.10.10
func (my *SetFormBodyError) Is(target error) bool
func (*SetFormBodyError) New ¶ added in v1.10.10
func (*SetFormBodyError) New(msg string) myError.IMyError
func (*SetFormBodyError) Panic ¶ added in v1.10.24
func (*SetFormBodyError) Panic() myError.IMyError
type SetJsonBodyError ¶ added in v1.10.10
func (*SetJsonBodyError) Error ¶ added in v1.10.10
func (my *SetJsonBodyError) Error() string
func (*SetJsonBodyError) Is ¶ added in v1.10.10
func (my *SetJsonBodyError) Is(target error) bool
func (*SetJsonBodyError) New ¶ added in v1.10.10
func (*SetJsonBodyError) New(msg string) myError.IMyError
func (*SetJsonBodyError) Panic ¶ added in v1.10.24
func (*SetJsonBodyError) Panic() myError.IMyError
type SetSteamBodyError ¶ added in v1.10.10
func (*SetSteamBodyError) Error ¶ added in v1.10.10
func (my *SetSteamBodyError) Error() string
func (*SetSteamBodyError) Is ¶ added in v1.10.10
func (my *SetSteamBodyError) Is(target error) bool
func (*SetSteamBodyError) New ¶ added in v1.10.10
func (*SetSteamBodyError) New(msg string) myError.IMyError
func (*SetSteamBodyError) Panic ¶ added in v1.10.24
func (*SetSteamBodyError) Panic() myError.IMyError
type SetXmlBodyError ¶ added in v1.10.10
func (*SetXmlBodyError) Error ¶ added in v1.10.10
func (my *SetXmlBodyError) Error() string
func (*SetXmlBodyError) Is ¶ added in v1.10.10
func (my *SetXmlBodyError) Is(target error) bool
func (*SetXmlBodyError) New ¶ added in v1.10.10
func (*SetXmlBodyError) New(msg string) myError.IMyError
func (*SetXmlBodyError) Panic ¶ added in v1.10.24
func (*SetXmlBodyError) Panic() myError.IMyError
type UnmarshalJsonError ¶ added in v1.10.10
func (*UnmarshalJsonError) Error ¶ added in v1.10.10
func (my *UnmarshalJsonError) Error() string
func (*UnmarshalJsonError) Is ¶ added in v1.10.10
func (my *UnmarshalJsonError) Is(target error) bool
func (*UnmarshalJsonError) New ¶ added in v1.10.10
func (*UnmarshalJsonError) New(msg string) myError.IMyError
func (*UnmarshalJsonError) Panic ¶ added in v1.10.24
func (*UnmarshalJsonError) Panic() myError.IMyError
type UnmarshalXmlError ¶ added in v1.10.10
func (*UnmarshalXmlError) Error ¶ added in v1.10.10
func (my *UnmarshalXmlError) Error() string
func (*UnmarshalXmlError) Is ¶ added in v1.10.10
func (my *UnmarshalXmlError) Is(target error) bool
func (*UnmarshalXmlError) New ¶ added in v1.10.10
func (*UnmarshalXmlError) New(msg string) myError.IMyError
func (*UnmarshalXmlError) Panic ¶ added in v1.10.24
func (*UnmarshalXmlError) Panic() myError.IMyError
type UrlEmptyError ¶ added in v1.10.10
func (*UrlEmptyError) Error ¶ added in v1.10.10
func (my *UrlEmptyError) Error() string
func (*UrlEmptyError) Is ¶ added in v1.10.10
func (my *UrlEmptyError) Is(target error) bool
func (*UrlEmptyError) New ¶ added in v1.10.10
func (*UrlEmptyError) New(msg string) myError.IMyError
func (*UrlEmptyError) Panic ¶ added in v1.10.24
func (*UrlEmptyError) Panic() myError.IMyError
type WriteResponseError ¶ added in v1.10.20
func (*WriteResponseError) Error ¶ added in v1.10.20
func (my *WriteResponseError) Error() string
func (*WriteResponseError) Is ¶ added in v1.10.20
func (my *WriteResponseError) Is(target error) bool
func (*WriteResponseError) New ¶ added in v1.10.20
func (*WriteResponseError) New(msg string) myError.IMyError
func (*WriteResponseError) Panic ¶ added in v1.10.24
func (*WriteResponseError) Panic() myError.IMyError