Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) DoDelete(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoDeleteWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoDeleteWithHeaders(ctx context.Context, url string, headers *http.Header, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoDeleteWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoGet(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoGetWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoGetWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoGetWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoHead(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoHeadWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoHeadWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoHeadWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoOptions(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoOptionsWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoOptionsWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoOptionsWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoPatch(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoPatchWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPatchWithHeaders(ctx context.Context, url string, headers *http.Header, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPatchWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoPost(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoPostWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPostWithHeaders(ctx context.Context, url string, headers *http.Header, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPostWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) DoPut(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
- func (c *Client) DoPutWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPutWithHeaders(ctx context.Context, url string, headers *http.Header, body string, ...) (result *HttpResponse, err error)
- func (c *Client) DoPutWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, ...) (result *HttpResponse, err error)
- func (c *Client) Exec(ctx context.Context, request *HttpRequest) (result *HttpResponse, err error)
- type HttpRequest
- type HttpResponse
Constants ¶
const ( MethodGet = "GET" MethodPost = "POST" MethodPut = "PUT" MethodPatch = "PATCH" MethodDelete = "DELETE" MethodOptions = "OPTIONS" MethodHead = "HEAD" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
var DefaultClient *Client
DefaultClient 超时时间为10秒的缺省实例指针
func (*Client) DoDelete ¶
func (c *Client) DoDelete(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
DoDelete Delete方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoDeleteWithCookies ¶
func (c *Client) DoDeleteWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, retryCount int) (result *HttpResponse, err error)
DoDeleteWithCookies Delete方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoDeleteWithHeaders ¶
func (c *Client) DoDeleteWithHeaders(ctx context.Context, url string, headers *http.Header, body string, retryCount int) (result *HttpResponse, err error)
DoDeleteWithHeaders Delete方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoDeleteWithHeadersAndCookies ¶
func (c *Client) DoDeleteWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, body string, retryCount int) ( result *HttpResponse, err error)
DoDeleteWithHeadersAndCookies Delete方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoGet ¶
func (c *Client) DoGet(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
DoGet GET方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoGetWithCookies ¶
func (c *Client) DoGetWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoGetWithCookies GET方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoGetWithHeaders ¶
func (c *Client) DoGetWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
DoGetWithHeaders GET方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoGetWithHeadersAndCookies ¶
func (c *Client) DoGetWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoGetWithHeadersAndCookies GET方式访问URL,获取结果,是Exec的快捷方法 传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoHead ¶
func (c *Client) DoHead(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
DoHead Head方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoHeadWithCookies ¶
func (c *Client) DoHeadWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoHeadWithCookies Head方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoHeadWithHeaders ¶
func (c *Client) DoHeadWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
DoHeadWithHeaders Head方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoHeadWithHeadersAndCookies ¶
func (c *Client) DoHeadWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoHeadWithHeadersAndCookies Head方式访问URL,获取结果,是Exec的快捷方法 传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoOptions ¶
func (c *Client) DoOptions(ctx context.Context, url string, retryCount int) (result *HttpResponse, err error)
DoOptions Options方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoOptionsWithCookies ¶
func (c *Client) DoOptionsWithCookies(ctx context.Context, url string, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoOptionsWithCookies Options方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoOptionsWithHeaders ¶
func (c *Client) DoOptionsWithHeaders(ctx context.Context, url string, headers *http.Header, retryCount int) (result *HttpResponse, err error)
DoOptionsWithHeaders Options方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoOptionsWithHeadersAndCookies ¶
func (c *Client) DoOptionsWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, retryCount int) (result *HttpResponse, err error)
DoOptionsWithHeadersAndCookies Options方式访问URL,获取结果,是Exec的快捷方法 传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPatch ¶
func (c *Client) DoPatch(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
DoPatch Patch方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPatchWithCookies ¶
func (c *Client) DoPatchWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, retryCount int) (result *HttpResponse, err error)
DoPatchWithCookies Patch方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPatchWithHeaders ¶
func (c *Client) DoPatchWithHeaders(ctx context.Context, url string, headers *http.Header, body string, retryCount int) (result *HttpResponse, err error)
DoPatchWithHeaders Patch方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPatchWithHeadersAndCookies ¶
func (c *Client) DoPatchWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, body string, retryCount int) ( result *HttpResponse, err error)
DoPatchWithHeadersAndCookies Patch方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPost ¶
func (c *Client) DoPost(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
DoPost Post方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPostWithCookies ¶
func (c *Client) DoPostWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, retryCount int) (result *HttpResponse, err error)
DoPostWithCookies Post方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPostWithHeaders ¶
func (c *Client) DoPostWithHeaders(ctx context.Context, url string, headers *http.Header, body string, retryCount int) (result *HttpResponse, err error)
DoPostWithHeaders Post方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPostWithHeadersAndCookies ¶
func (c *Client) DoPostWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, body string, retryCount int) ( result *HttpResponse, err error)
DoPostWithHeadersAndCookies Post方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPut ¶
func (c *Client) DoPut(ctx context.Context, url string, body string, retryCount int) (result *HttpResponse, err error)
DoPut Put方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPutWithCookies ¶
func (c *Client) DoPutWithCookies(ctx context.Context, url string, cookies []*http.Cookie, body string, retryCount int) (result *HttpResponse, err error)
DoPutWithCookies Put方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPutWithHeaders ¶
func (c *Client) DoPutWithHeaders(ctx context.Context, url string, headers *http.Header, body string, retryCount int) (result *HttpResponse, err error)
DoPutWithHeaders Put方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) DoPutWithHeadersAndCookies ¶
func (c *Client) DoPutWithHeadersAndCookies(ctx context.Context, url string, headers *http.Header, cookies []*http.Cookie, body string, retryCount int) ( result *HttpResponse, err error)
DoPutWithHeadersAndCookies Put方式访问URL,获取结果,是Exec的快捷方法
传入参数:
ctx url 要访问的url header 请求的Http header cookies 请求的Http cookies body 请求的Http body retryCount 重试次数,如为-1则无限重试
返回参数
result HttpResponse结构体 err 错误
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, request *HttpRequest) (result *HttpResponse, err error)
Exec 通过给定方式访问URL,获取结果
传入参数:
ctx request HttpRequest 结构体
返回参数
result HttpResponse 结构体 err 错误