Documentation ¶
Index ¶
- type Client
- func (c *Client) DoRequest(method, url string, data ...interface{}) (resp *Response, err error)
- func (c *Client) SetAgent(agent string) *Client
- func (c *Client) SetBasicAuth(user, pass string) *Client
- func (c *Client) SetContentType(contentType string) *Client
- func (c *Client) SetCookie(key, value string) *Client
- func (c *Client) SetCookieMap(m map[string]string) *Client
- func (c *Client) SetCtx(ctx context.Context) *Client
- func (c *Client) SetHeader(key, value string) *Client
- func (c *Client) SetHeaderMap(m map[string]string) *Client
- func (c *Client) SetPrefix(prefix string) *Client
- func (c *Client) SetRetry(retryCount int, retryInterval time.Duration) *Client
- func (c *Client) SetTLSConfig(tlsConfig *tls.Config) error
- func (c *Client) SetTimeout(t time.Duration) *Client
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { http.Client // Underlying HTTP Client. // contains filtered or unexported fields }
func (*Client) DoRequest ¶
DoRequest sends request with given HTTP method and data and returns the response object. Note that the response object MUST be closed if it'll be never used.
Note that it uses "multipart/form-data" as its Content-Type if it contains file uploading, else it uses "application/x-www-form-urlencoded". It also automatically detects the post content for JSON format, and for that it automatically sets the Content-Type as "application/json".
func (*Client) SetBasicAuth ¶
SetBasicAuth sets HTTP basic authentication information for the client.
func (*Client) SetContentType ¶
SetContentType sets HTTP content type for the client.
func (*Client) SetCookieMap ¶
SetCookieMap sets cookie items with map.
func (*Client) SetHeaderMap ¶
SetHeaderMap sets custom HTTP headers with map.
func (*Client) SetTLSConfig ¶
SetTLSConfig sets the TLS configuration of client.
type Response ¶
Response is the struct for client request response.
func (*Response) GetCookieMap ¶
GetCookieMap retrieves and returns a copy of current cookie values map.
func (*Response) ReadAllString ¶
ReadAllString retrieves and returns the response content as string.