httpclient

package
v0.43.3-0...-9926edd Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResponseBody

func GetResponseBody(client Client, request *http.Request) (_ []byte, retErr error)

GetResponseBody reads and closes the response body.

Types

type Client

type Client interface {
	// Do matches http.Client.
	//
	// This allows Client to be dropped in for http.Client.
	Do(request *http.Request) (*http.Response, error)
	// ParseAddress parses the given address.
	//
	// If the address has a scheme, this is a no-op.
	// If the address does not have a scheme, this adds https:// if TLS was configured,
	// and http:// if TLS was not configured.
	ParseAddress(address string) string
	// Transport returns the http.RoundTripper configured on
	// this client.
	Transport() http.RoundTripper
}

Client is a client.

func NewClient

func NewClient(options ...ClientOption) (Client, error)

NewClient returns a new Client.

func NewClientWithTransport

func NewClientWithTransport(transport http.RoundTripper) (Client, error)

NewClientWithTransport returns a new Client with the given transport. This is a separate constructor so that it's clear it cannot be used in combination with other ClientOptions.

type ClientOption

type ClientOption func(*client)

ClientOption is an option for a new Client.

func ClientWithObservability

func ClientWithObservability() ClientOption

ClientWithObservability returns a new ClientOption to use OpenCensus tracing and metrics.

The default is to use no observability.

func ClientWithTLSConfig

func ClientWithTLSConfig(tlsConfig *tls.Config) ClientOption

ClientWithTLSConfig returns a new ClientOption to use the tls.Config.

The default is to use no TLS.

Jump to

Keyboard shortcuts

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