http

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func (c *Client) GetMaxRetries() int

GetMaxRetries returns the configured max retries

func (*Client) GetRestyClient

func (c *Client) GetRestyClient() *resty.Client

GetRestyClient returns the underlying resty client This is useful for integrations that need the raw client (e.g., GraphQL)

func (*Client) GetTimeout

func (c *Client) GetTimeout() time.Duration

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) SetHeader

func (c *Client) SetHeader(key, value string)

SetHeader sets a default header for all requests

func (*Client) SetHeaders

func (c *Client) SetHeaders(headers map[string]string)

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

Jump to

Keyboard shortcuts

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