auresthttpclient

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instrument added in v0.4.0

func Instrument(
	client aurestclientapi.Client,
	requestMetricsCallback aurestclientapi.MetricsCallbackFunction,
	responseMetricsCallback aurestclientapi.MetricsCallbackFunction,
)

Instrument adds instrumentation to a http client.

Either of the callbacks may be nil.

func New

func New(timeout time.Duration, customCACert []byte, requestManipulator aurestclientapi.RequestManipulatorCallback) (aurestclientapi.Client, error)

New builds a new http client.

Do not share between different logging/circuit breaker/retry stacks, but you should only build each stack once.

timeout MUST be set to 0 if you use a circuit breaker or anything else that may do a context cancel, or you'll get weird behavior.

If len(customCACert) is 0, the default CA certificates are used, but if you specify it, they are excluded to ensure only your certs are accepted.

Types

type AuRestHttpClient added in v0.9.0

type AuRestHttpClient struct {
	*http.Client

	// Now is exposed so tests can fixate the time by overwriting this field
	Now func() time.Time
}

func NewHttpClient added in v0.9.0

func NewHttpClient(timeout time.Duration, customCACert []byte,
	requestManipulator aurestclientapi.RequestManipulatorCallback, customHttpTransport *http.RoundTripper) (*AuRestHttpClient, error)

type HttpClientImpl

type HttpClientImpl struct {
	HttpClient         *http.Client
	RequestManipulator aurestclientapi.RequestManipulatorCallback
	Timeout            time.Duration

	RequestMetricsCallback  aurestclientapi.MetricsCallbackFunction
	ResponseMetricsCallback aurestclientapi.MetricsCallbackFunction

	// Now is exposed so tests can fixate the time by overwriting this field
	Now func() time.Time
}

func (*HttpClientImpl) Perform

func (c *HttpClientImpl) Perform(ctx context.Context, method string, requestUrl string, requestBody interface{}, response *aurestclientapi.ParsedResponse) error

type HttpClientRoundTripper added in v0.9.0

type HttpClientRoundTripper struct {
	RequestManipulator      aurestclientapi.RequestManipulatorCallback
	RequestMetricsCallback  aurestclientapi.MetricsCallbackFunction
	ResponseMetricsCallback aurestclientapi.MetricsCallbackFunction
	// contains filtered or unexported fields
}

func (*HttpClientRoundTripper) RoundTrip added in v0.9.0

func (c *HttpClientRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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