request

package
v0.0.0-...-8dfd213 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetProxy

func SetProxy(transport *http.Transport, proxyURL string)

Types

type Client

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

Client represents an HTTP client with additional capabilities

func Default

func Default() *Client

func New

func New(options ...ClientOption) *Client

New creates a new HTTP client with the specified options

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do performs an HTTP request with retries for certain status codes

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) MakeRequest

func (c *Client) MakeRequest(req *http.Request) ([]byte, error)

MakeRequest performs an HTTP request and returns the response body as bytes

func (*Client) SetHeader

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

type ClientOption

type ClientOption func(*Client)

func WithHeaders

func WithHeaders(headers map[string]string) ClientOption

WithHeaders sets default headers

func WithLogger

func WithLogger(logger zerolog.Logger) ClientOption

func WithMaxRetries

func WithMaxRetries(maxRetries int) ClientOption

WithMaxRetries sets the maximum number of retry attempts

func WithProxy

func WithProxy(proxyURL string) ClientOption

func WithRateLimiter

func WithRateLimiter(rl ratelimit.Limiter) ClientOption

WithRateLimiter sets a rate limiter

func WithRetryableStatus

func WithRetryableStatus(statusCodes ...int) ClientOption

WithRetryableStatus adds status codes that should trigger a retry

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the request timeout

func WithTransport

func WithTransport(transport *http.Transport) ClientOption

Jump to

Keyboard shortcuts

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