httpclient

package
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicHttpClient

type BasicHttpClient struct {
	HeaderProvider []HTTPHeaderProvider
}

func NewBasicHttpClient

func NewBasicHttpClient() *BasicHttpClient

func (*BasicHttpClient) DoWithContext

func (b *BasicHttpClient) DoWithContext(ctx context.Context, request *http.Request) (*http.Response, error)

DoWithContext implements HttpClient.

func (*BasicHttpClient) WithHeaderProvider

func (b *BasicHttpClient) WithHeaderProvider(headerProvider ...HTTPHeaderProvider) *BasicHttpClient

WithHeaderProvider creates a new BasicHttpClient with given header provider additionally.

type HTTPClient

type HTTPClient[T any] interface {
	// DoWithContext send request to
	DoWithContext(ctx context.Context, request *http.Request) (T, error)
}

An interface to mock *http.Client

type HTTPHeaderProvider

type HTTPHeaderProvider interface {
	// AddHeader adds headers on outgoing request.
	AddHeader(req *http.Request) error
}

HTTPHeaderProvider adds header on outgoing requests.

type JSONReponseHttpClient

type JSONReponseHttpClient[T any] struct {
	// contains filtered or unexported fields
}

func NewJsonResponseHttpClient

func NewJsonResponseHttpClient[T any](client HTTPClient[*http.Response]) *JSONReponseHttpClient[T]

func (*JSONReponseHttpClient[T]) DoWithContext

func (p *JSONReponseHttpClient[T]) DoWithContext(ctx context.Context, request *http.Request) (*T, *http.Response, error)

type RetryHttpClient

type RetryHttpClient struct {
	Client                             HTTPClient[*http.Response]
	MinWaitSeconds                     int
	MaxWaitSeconds                     int
	MaxRetryCount                      int
	RetriableHttpCodes                 []int
	RetriableWithRefreshTokenHttpCodes []int
	// contains filtered or unexported fields
}

func NewRetryHttpClient

func NewRetryHttpClient(baseClient HTTPClient[*http.Response], minWaitSeconds int, maxWaitSeconds int, maxRetryCount int, retriableHttpCodes []int, retriableWithRefreshTokenHttpCodes []int, tokenRefresher token.TokenRefresher) *RetryHttpClient

func (*RetryHttpClient) DoWithContext

func (r *RetryHttpClient) DoWithContext(ctx context.Context, originalRequest *http.Request) (*http.Response, error)

DoWithContext implements HttpClient.

Jump to

Keyboard shortcuts

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