httpclient

package
v0.0.0-...-f5bbbf4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 5 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 interface {
	// Do sends an HTTP request and returns an HTTP response, following
	// policy (such as redirects, cookies, auth)
	Do(*http.Request) (*http.Response, error)

	// CloseIdleConnections closes any connections on its Transport which
	// were previously connected from previous requests but are now
	// sitting idle in a "keep-alive" state. It does not interrupt any
	// connections currently in use.
	CloseIdleConnections()
}

Client is an HTTP client

func New

func New(
	cfg *Config,
	trnsprt http.RoundTripper,
) (Client, error)

New creates a new HTTP client

type Config

type Config struct {
	Transport *transport.Config `json:"transport,omitempty"`
	Timeout   *json.Duration    `json:"timeout,omitempty"`
}

Config for creating an HTTP Client

func (*Config) SetDefault

func (cfg *Config) SetDefault() *Config

type Decorator

type Decorator func(Client) Client

Decorator decorates a Client

func CombineDecorators

func CombineDecorators(decorators ...Decorator) Decorator

func WithModifier

func WithModifier(modifier response.Modifier) Decorator

func WithPreparer

func WithPreparer(preparer request.Preparer) Decorator

func WithRequest

func WithRequest(req *http.Request) Decorator

Jump to

Keyboard shortcuts

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