http

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithApiHeaderFn

func WithApiHeaderFn(fn ApiHeaderFn) option

WithApiHeaderFn returns an option that sets a function to add API headers to requests

func WithHttpClient

func WithHttpClient(client *http.Client) option

WithHttpClient returns an option that sets the HTTP client used by the Client

Types

type APIError added in v3.0.3

type APIError struct {
	StatusCode int
	Body       []byte
}

APIError is an error returned by the client when the API returns a non-200 status code

func (*APIError) Error added in v3.0.3

func (e *APIError) Error() string

type ApiHeaderFn

type ApiHeaderFn func(*http.Request)

ApiHeaderFn is a function type that sets headers on HTTP requests

type Client

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

Client is an HTTP client that can make API requests with optional headers

func NewClient

func NewClient(opts ...option) *Client

NewClient creates a new Client with the given options

func (*Client) MakeReq

func (c *Client) MakeReq(ctx context.Context, url string) ([]byte, error)

MakeReq makes a GET request to the given URL with the configured client It returns the response body as bytes or an error if the request fails

Jump to

Keyboard shortcuts

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