Documentation
¶
Index ¶
- func DoWithRetry(ctx context.Context, client *http.Client, req *http.Request, maxRetries int, ...) (*http.Response, error)
- func DrainAndClose(body io.ReadCloser)
- func NewHTTPClient() *http.Client
- func NewHTTPClientWithConfig(cfg HTTPClientConfig) *http.Client
- func NewRequestWithJSON(ctx context.Context, method, url string, body []byte) (*http.Request, error)
- func ReadResponseBody(resp *http.Response, maxSize int64) ([]byte, error)
- type HTTPClientConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoWithRetry ¶
func DoWithRetry(ctx context.Context, client *http.Client, req *http.Request, maxRetries int, baseDelay time.Duration) (*http.Response, error)
DoWithRetry performs an HTTP request with exponential backoff retry
func DrainAndClose ¶
func DrainAndClose(body io.ReadCloser)
DrainAndClose drains and closes a response body
func NewHTTPClient ¶
NewHTTPClient creates a new HTTP client with standard configuration
func NewHTTPClientWithConfig ¶
func NewHTTPClientWithConfig(cfg HTTPClientConfig) *http.Client
NewHTTPClientWithConfig creates a new HTTP client with custom configuration
Types ¶
type HTTPClientConfig ¶
type HTTPClientConfig struct {
Timeout time.Duration
MaxRetries int
RetryBaseDelay time.Duration
Debug bool
ConnectTimeout time.Duration
}
HTTPClientConfig configures the HTTP client behavior
func DefaultHTTPConfig ¶
func DefaultHTTPConfig() HTTPClientConfig
DefaultHTTPConfig returns the default HTTP client configuration
Click to show internal directories.
Click to hide internal directories.