client

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MPL-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 is a small context-aware HTTP client for Open Data Hub API calls.

func New

func New(timeout time.Duration) *Client

New creates a client with the provided timeout and default retries.

func NewWithHTTPClient

func NewWithHTTPClient(httpClient *http.Client, userAgent string) *Client

NewWithHTTPClient creates a client around an injected HTTP client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (Response, error)

Get performs an HTTP GET and returns the response body for 2xx responses.

func (*Client) GetCached added in v0.1.10

func (c *Client) GetCached(ctx context.Context, url string, ttl time.Duration) (Response, error)

GetCached performs an HTTP GET with local file caching.

func (*Client) GetWithLimit added in v0.1.5

func (c *Client) GetWithLimit(ctx context.Context, url string, limitBytes int64) (Response, error)

GetWithLimit performs an HTTP GET and reads at most limitBytes bytes.

func (*Client) WithRetryPolicy added in v0.1.10

func (c *Client) WithRetryPolicy(maxRetries int, baseDelay time.Duration) *Client

WithRetryPolicy returns a copy of the client with custom retry behavior.

func (*Client) WithTimeout added in v0.1.7

func (c *Client) WithTimeout(timeout time.Duration) *Client

WithTimeout returns a copy of the client with a different HTTP timeout.

func (*Client) WithTransport added in v0.1.10

func (c *Client) WithTransport(transport http.RoundTripper) *Client

WithTransport returns a copy of the client using a specific RoundTripper.

type HTTPError

type HTTPError struct {
	URL         string
	StatusCode  int
	ContentType string
	Body        string
}

HTTPError captures a non-2xx response.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Response

type Response struct {
	URL         string
	StatusCode  int
	ContentType string
	Body        []byte
	FromCache   bool
}

Response contains the raw response body and selected metadata.

Jump to

Keyboard shortcuts

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