client

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MPL-2.0 Imports: 7 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 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.

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

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
}

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