Documentation
¶
Index ¶
- type Client
- func (c *Client) Get(ctx context.Context, url string, headers map[string]string) (*resty.Response, error)
- func (c *Client) GetMaxRetries() int
- func (c *Client) GetRestyClient() *resty.Client
- func (c *Client) GetTimeout() time.Duration
- func (c *Client) Post(ctx context.Context, url string, body interface{}, headers map[string]string) (*resty.Response, error)
- func (c *Client) SetHeader(key, value string)
- func (c *Client) SetHeaders(headers map[string]string)
- type ClientConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps resty.Client with retry logic and timeout handling
func NewClient ¶
func NewClient(config ClientConfig) *Client
NewClient creates a new HTTP client with the given configuration
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, url string, headers map[string]string) (*resty.Response, error)
Get performs a GET request with context support
func (*Client) GetMaxRetries ¶
GetMaxRetries returns the configured max retries
func (*Client) GetRestyClient ¶
GetRestyClient returns the underlying resty client This is useful for integrations that need the raw client (e.g., GraphQL)
func (*Client) GetTimeout ¶
GetTimeout returns the configured timeout
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, url string, body interface{}, headers map[string]string) (*resty.Response, error)
Post performs a POST request with context support
func (*Client) SetHeaders ¶
SetHeaders sets multiple default headers
type ClientConfig ¶
type ClientConfig struct {
Timeout time.Duration
MaxRetries int
UserAgent string
Debug bool
Logger *slog.Logger
}
ClientConfig holds configuration for the HTTP client
func DefaultClientConfig ¶
func DefaultClientConfig() ClientConfig
DefaultClientConfig returns sensible defaults for HTTP client
Click to show internal directories.
Click to hide internal directories.