httpx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package httpx wraps net/http with a User-Agent and retry on 5xx/429 (honoring Retry-After). The client has no Timeout — use context.

Index

Constants

View Source
const (
	DefaultMaxRetries = 3
	DefaultBackoff    = 300 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP       *http.Client
	UserAgent  string
	MaxRetries int
	Backoff    time.Duration
}

Client adds a User-Agent and bounded retry on 5xx, 429, and network errors. Safe for concurrent use.

func New

func New(userAgent string) *Client

func (*Client) Do

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

Do sends req, retrying transient failures with exponential backoff or the server's Retry-After. Callers must close Response.Body.

func (*Client) GetJSON

func (c *Client) GetJSON(ctx context.Context, rawURL string, dest any) error

GetJSON GETs rawURL and decodes the body into dest.

Jump to

Keyboard shortcuts

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