roundtripper

package
v3.80.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBasicAuth

func WithBasicAuth(username, password string) func(*RoundTripper)

func WithDefault429RetryDuration

func WithDefault429RetryDuration(duration time.Duration) func(*RetryableRoundtripper)

func WithInsecureTLS

func WithInsecureTLS() func(*RoundTripper)

WithInsecureTLS will disable TLS verification.

func WithLogger

func WithLogger(log logr.Logger) func(*RoundTripper)

func WithLogging

func WithLogging() func(*RoundTripper)

func WithMaxRetries

func WithMaxRetries(max uint) func(*RetryableRoundtripper)

func WithRetryable

func WithRetryable(opts ...func(*RetryableRoundtripper)) func(*RoundTripper)

func WithShouldRetry401Duration

func WithShouldRetry401Duration(duration time.Duration) func(*RetryableRoundtripper)

func WithShouldRetry5XX

func WithShouldRetry5XX(should bool) func(*RetryableRoundtripper)

func WithShouldRetry5XXDuration

func WithShouldRetry5XXDuration(duration time.Duration) func(*RetryableRoundtripper)

func WithShouldRetryError

func WithShouldRetryError(should bool) func(*RetryableRoundtripper)

func WithShouldRetryErrorDuration

func WithShouldRetryErrorDuration(duration time.Duration) func(*RetryableRoundtripper)

Types

type BasicAuthRoundTripper

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

type LoggingRoundtripper

type LoggingRoundtripper struct{}

type RetryableRoundtripper

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

type RoundTripper

type RoundTripper struct {
	*BasicAuthRoundTripper
	*RetryableRoundtripper
	*LoggingRoundtripper
	// contains filtered or unexported fields
}

func NewRoundTripper

func NewRoundTripper(original http.RoundTripper, opts ...func(*RoundTripper)) *RoundTripper

NewRoundTripper creates a new RoundTripper instance tailored for the application's specific needs. This custom RoundTripper provides a centralized place to manage outbound HTTP requests. By allowing configuration through functional options, it provides a clear, extensible, and maintainable way to adjust the behavior of HTTP calls. This ensures consistent logging, error handling, and other behaviors across all HTTP requests made in the application, reducing potential points of failure and simplifying debugging.

func (*RoundTripper) RoundTrip

func (r *RoundTripper) 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