Documentation
¶
Index ¶
- Constants
- func GetRestyClient(cfg Config) *resty.Client
- func InitHTTPClient(conf Config, logger *zap.Logger)
- type Client
- func (c Client) EncodeWithSha256(rawStr string) (string, error)
- func (c Client) Get(ctx context.Context, url string, headers map[string]string, ...) ([]byte, error)
- func (c Client) JoinStringsInASCII(data map[string]interface{}, sep string, includeEmpty bool, ...) string
- func (c Client) Post(ctx context.Context, url string, headers map[string]string, body interface{}, ...) ([]byte, error)
- func (c Client) PostForm(ctx context.Context, url string, param map[string]string, result interface{}) ([]byte, error)
- func (c Client) SetProxy(proxyUrl string)
- func (c Client) ToMap(context interface{}) (map[string]interface{}, error)
- type Config
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func GetRestyClient ¶
func GetRestyClient(cfg Config) *resty.Client
func InitHTTPClient ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
var HTTPClient *Client
func (Client) JoinStringsInASCII ¶
func (c Client) JoinStringsInASCII(data map[string]interface{}, sep string, includeEmpty bool, exceptKeys ...string) string
JoinStringsInASCII 排序 data 排序内容 sep 连接符 includeEmpty 是否包含空值,true则包含空值,否则不包含,注意此参数不影响参数名的存在 exceptKeys 被排除的参数名,不参与排序及拼接
type Config ¶
type Config struct { Debug bool `toml:"Debug" yaml:"debug"` Verbose bool `toml:"Verbose" yaml:"verbose" default:"false"` // 请求输出详细的调试信息 Timeout string `toml:"Timeout" yaml:"timeout" default:"5s"` // 请求超时时间 DialTimeout string `toml:"DialTimeout" yaml:"dial_timeout" default:"30s"` // 连接池DialTimeout IdleConnTimeout string `toml:"IdleConnTimeout" yaml:"idle_conn_timeout" default:"90s"` // 连接空闲最长时间 MaxIdleConns int `toml:"MaxIdleConns" yaml:"max_idle_conns" default:"0"` // 最大空闲 MaxIdleConnsPerHost int `toml:"MaxIdleConnsPerHost" yaml:"max_idle_conns_per_host" default:"500"` // 单个host最大空闲 MaxConnsPerHost int `toml:"MaxConnsPerHost" yaml:"max_conns_per_host" default:"2000"` // 单个host允许最大连接 DisableKeepAlives bool `toml:"DisableKeepAlives" yaml:"disable_keep_alives"` // 为true时,强制禁用HTTP协议的keep-alive功能 }
func (Config) GetHTTPDialTimeout ¶
func (Config) GetHTTPIdleConnTimeout ¶
func (Config) GetHTTPTimeout ¶
Click to show internal directories.
Click to hide internal directories.