requestbuilder

package
v0.0.0-...-059733a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxRetries         = 5
	DefaultTimeout            = 10 * time.Second
	DefaultBaseExpJitterDelay = 100 * time.Millisecond
	DefaultMaxExpJitterDelay  = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoCacheTransport

type AutoCacheTransport struct {
	Transport http.RoundTripper
	Cache     *cache.Cache[string]
	CacheKey  string
}

func NewAutoCacheTransport

func NewAutoCacheTransport(transport http.RoundTripper, cache *cache.Cache[string], cacheKey string) AutoCacheTransport

func (AutoCacheTransport) RoundTrip

func (t AutoCacheTransport) RoundTrip(req *http.Request) (*http.Response, error)

type RequestBuilder

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

func New

func New(method, url string) *RequestBuilder

func (*RequestBuilder) Build

func (r *RequestBuilder) Build(ctx context.Context) (*http.Request, error)

func (*RequestBuilder) Do

func (*RequestBuilder) WithBody

func (r *RequestBuilder) WithBody(input any) *RequestBuilder

func (*RequestBuilder) WithCache

func (r *RequestBuilder) WithCache(cache *cache.Cache[string], key string) *RequestBuilder

func (*RequestBuilder) WithClient

func (r *RequestBuilder) WithClient(httpClient *http.Client) *RequestBuilder

func (*RequestBuilder) WithCustomRetry

func (r *RequestBuilder) WithCustomRetry(retryFn rehttp.RetryFn, delayFn rehttp.DelayFn) *RequestBuilder

func (*RequestBuilder) WithHeader

func (r *RequestBuilder) WithHeader(key string, values ...string) *RequestBuilder

func (*RequestBuilder) WithInvalidateCache

func (r *RequestBuilder) WithInvalidateCache(cache *cache.Cache[string], keys ...string) *RequestBuilder

func (*RequestBuilder) WithPathParam

func (r *RequestBuilder) WithPathParam(key string, value string) *RequestBuilder

func (*RequestBuilder) WithQueryParam

func (r *RequestBuilder) WithQueryParam(key string, values ...string) *RequestBuilder

func (*RequestBuilder) WithRetry

func (r *RequestBuilder) WithRetry(additionalStatuses ...int) *RequestBuilder

func (*RequestBuilder) WithSetCacheFn

func (r *RequestBuilder) WithSetCacheFn(cache *cache.Cache[string], setCacheFns ...SetCacheFn) *RequestBuilder

func (*RequestBuilder) WithTimeout

func (r *RequestBuilder) WithTimeout(timeout time.Duration) *RequestBuilder

type SetCacheFn

type SetCacheFn func() (string, any)

type SetCacheTransport

type SetCacheTransport struct {
	Transport http.RoundTripper
	Cache     *cache.Cache[string]
	SetFns    []SetCacheFn
}

func NewSetCacheTransport

func NewSetCacheTransport(transport http.RoundTripper, cache *cache.Cache[string], setFns ...SetCacheFn) SetCacheTransport

func (SetCacheTransport) RoundTrip

func (t SetCacheTransport) 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