Documentation
¶
Index ¶
- type Client
- func (c *Client) AddHeader(key, value string) *Client
- func (c *Client) Debug(debug bool) *Client
- func (c *Client) Delete(ctx ictx.Context, url string) (*Response, error)
- func (c *Client) Do(ctx ictx.Context, req *Request) (*Response, error)
- func (c *Client) DoWithRetry(ctx ictx.Context, req *Request) (*Response, error)
- func (c *Client) Get(ctx ictx.Context, url string) (*Response, error)
- func (c *Client) GetBodyString(ctx ictx.Context, method, url string, body interface{}) (string, error)
- func (c *Client) GetJSON(ctx ictx.Context, url string, target interface{}) error
- func (c *Client) Post(ctx ictx.Context, url string, body interface{}) (*Response, error)
- func (c *Client) PostForm(ctx ictx.Context, url string, data url.Values) (*Response, error)
- func (c *Client) PostJSON(ctx ictx.Context, url string, data interface{}, target interface{}) error
- func (c *Client) Put(ctx ictx.Context, url string, body interface{}) (*Response, error)
- func (c *Client) SetBaseURL(baseURL string) *Client
- func (c *Client) SetDefaultRetries(maxRetries int) *Client
- func (c *Client) SetDefaultTimeout(timeout time.Duration) *Client
- func (c *Client) SetHeader(key, value string) *Client
- func (c *Client) SetHeaders(headers map[string]string) *Client
- func (c *Client) SetTLSClientConfig(config *tls.Config) *Client
- func (c *Client) SetUserAgent(userAgent string) *Client
- type Request
- type Response
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.2.0
type Client struct {
// contains filtered or unexported fields
}
Client 简化的HTTP客户端
func NewWithTimeout ¶ added in v0.2.0
NewWithTimeout 创建带超时的HTTP客户端
func (*Client) DoWithRetry ¶ added in v0.2.0
DoWithRetry 执行HTTP请求(带重试功能)
func (*Client) GetBodyString ¶ added in v0.2.0
func (c *Client) GetBodyString(ctx ictx.Context, method, url string, body interface{}) (string, error)
GetBodyString 获取响应体字符串的便捷方法(支持任何HTTP方法)
func (*Client) SetBaseURL ¶ added in v0.2.0
SetBaseURL 设置基础URL
func (*Client) SetDefaultRetries ¶ added in v0.2.0
SetDefaultRetries 设置默认重试次数
func (*Client) SetDefaultTimeout ¶ added in v0.2.0
SetDefaultTimeout 设置默认超时时间
func (*Client) SetHeaders ¶ added in v0.2.0
SetHeaders 批量设置默认请求头
func (*Client) SetTLSClientConfig ¶ added in v0.2.0
SetTLSClientConfig 设置TLS配置
func (*Client) SetUserAgent ¶ added in v0.2.0
SetUserAgent 设置User-Agent
Click to show internal directories.
Click to hide internal directories.