Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Kernel() *resty.Client OnBeforeRequest(hooks ...hook.RequestHook) Client OnAfterResponse(hooks ...hook.ResponseHook) Client NewRequest(ctx context.Context) *resty.Request PostJSON(ctx context.Context, path string, values interface{}, headers http.Header, ret interface{}) error PostForm(ctx context.Context, path string, values url.Values, headers http.Header, ret interface{}) error Get(ctx context.Context, path string, values url.Values, headers http.Header, ret interface{}) error }
func GetGlobalClient ¶
func GetGlobalClient() Client
func NewClientWithConfig ¶
func NewGlobalClient ¶
NewGlobalClient If there is only one http client, you can select the global client
type Config ¶
type Config struct { Host string `mapstructure:"host" json:"host"` Timeout time.Duration `mapstructure:"timeout" json:"timeout"` // 单位:s RetryCount int `mapstructure:"retry_count" json:"retry_count"` // 重试次数 RetryWaitTime time.Duration `mapstructure:"retry_wait_time" json:"retry_wait_time"` // 重试间隔等待时间, 单位:s RetryMaxWaitTime time.Duration `mapstructure:"retry_max_wait_time" json:"retry_max_wait_time"` // 重试间隔最大等待时间, 单位:s Alias string `mapstructure:"alias" json:"alias"` }
type Manager ¶
type Manager interface { Add(alias string, c Client) Delete(alias string) Get(alias string) (Client, error) Has(alias string) bool }
func ClientManager ¶
func ClientManager() Manager
type Option ¶
type Option func(*Config)
func WithRetryCount ¶
func WithRetryMaxWaitTime ¶
func WithRetryWaitTime ¶
func WithTimeout ¶
Click to show internal directories.
Click to hide internal directories.