myhttp

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormRequest added in v1.0.7

func FormRequest() *resty.Request

func JsonRequest added in v1.0.7

func JsonRequest() *resty.Request

func Request added in v1.0.7

func Request() *resty.Request

Types

type Config

type Config struct {
	MaxIdleConnections    int           // 连接池的最大空闲连接数 / Maximum idle connections in the connection pool
	IdleConnectionTimeout time.Duration // 空闲连接超时时间 / Timeout for idle connections
	DisableCompression    bool          // 禁用压缩 / Disable compression
	DisableKeepAlives     bool          // 禁用 keep-alive / Disable keep-alive
	InsecureSkipVerify    bool          // 跳过 TLS 证书验证 / Skip TLS certificate verification
	Timeout               time.Duration // 总超时时间 / Total timeout duration
	TLSHandshakeTimeout   time.Duration // TLS 握手超时时间 / Timeout for TLS handshake
	ExpectContinueTimeout time.Duration // 100-continue 超时时间 / Timeout for 100-continue
	MaxConnectionsPerHost int           // 每主机的最大连接数 / Maximum connections per host
	RetryAttempts         int           // 请求重试次数 / Number of retry attempts for failed requests
	DialerTimeout         time.Duration // Dialer 的连接超时时间 / Dialer connection timeout
	DialerKeepAlive       time.Duration // Dialer 的 Keep-Alive 时间 / Dialer keep-alive time
	RetryWaitTime         time.Duration // 重试等待时间 / RetryWaitTime
	RetryMaxWaitTime      time.Duration // 最大重试等待时间 / RetryMaxWaitTime
	UserAgent             string        // 默认全局 UserAgent
}

Config 包含 HTTP 客户端的配置选项 Config contains the configuration options for the HTTP client

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

HttpClient 是对 Resty 客户端的封装,支持自定义配置和日志 / HttpClient is a wrapper for the Resty client with custom configuration and logging support

func Client added in v1.0.7

func Client() *HttpClient

func New

func New(config *Config) *HttpClient

New 创建一个新的 HTTP 客户端实例 / NewHttpClient creates a new HTTP client instance

func (*HttpClient) SetLog

func (h *HttpClient) SetLog(logger *zap.Logger) *HttpClient

SetLog 设置日志记录器 / SetLog sets the logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL