httpclient

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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