http

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserAgentHeaderKey is the key for the User-Agent header.
	UserAgentHeaderKey = "User-Agent"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a wrapper around the Go stdlib http client.

func NewClient

func NewClient() *Client

NewClient returns a new Client with its internal http client set to the default client.

func (*Client) GetWithContext

func (c *Client) GetWithContext(ctx context.Context, url string, opts ...GetOptions) (*http.Response, error)

GetWithContext performs a Get request with the context provided.

type GetOptions

type GetOptions func(*http.Request)

func WithHeader

func WithHeader(key, value string) GetOptions

func WithJSONAccept

func WithJSONAccept() GetOptions

type HeaderOption

type HeaderOption func(map[string]string)

HeaderOption is a function that sets a (key, value) pair in the headers map.

func WithAuthentication

func WithAuthentication(key, token string) HeaderOption

func WithSlinkyVersionUserAgent

func WithSlinkyVersionUserAgent() HeaderOption

type RoundTripperWithHeaders

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

RoundTripperWithHeaders is a round tripper that adds headers to the request.

func NewRoundTripperWithHeaders

func NewRoundTripperWithHeaders(next http.RoundTripper, headerOptions ...HeaderOption) *RoundTripperWithHeaders

NewRoundTripperWithHeaders creates a new RoundTripperWithHeaders.

func (*RoundTripperWithHeaders) RoundTrip

func (r *RoundTripperWithHeaders) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip updates the Requests' headers with the headers specified in the constructor, and calls the underlying RoundTripper.

Jump to

Keyboard shortcuts

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