client

package
v0.1.6 Latest Latest
Warning

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

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

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.

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