Documentation ¶
Index ¶
- Constants
- type AutoCacheTransport
- type RequestBuilder
- func (r *RequestBuilder) Build(ctx context.Context) (*http.Request, error)
- func (r *RequestBuilder) Do(ctx context.Context) (*http.Response, error)
- func (r *RequestBuilder) WithBody(input any) *RequestBuilder
- func (r *RequestBuilder) WithCache(cache *cache.Cache[string], key string) *RequestBuilder
- func (r *RequestBuilder) WithClient(httpClient *http.Client) *RequestBuilder
- func (r *RequestBuilder) WithCustomRetry(retryFn rehttp.RetryFn, delayFn rehttp.DelayFn) *RequestBuilder
- func (r *RequestBuilder) WithHeader(key string, values ...string) *RequestBuilder
- func (r *RequestBuilder) WithInvalidateCache(cache *cache.Cache[string], keys ...string) *RequestBuilder
- func (r *RequestBuilder) WithPathParam(key string, value string) *RequestBuilder
- func (r *RequestBuilder) WithQueryParam(key string, values ...string) *RequestBuilder
- func (r *RequestBuilder) WithRetry(additionalStatuses ...int) *RequestBuilder
- func (r *RequestBuilder) WithSetCacheFn(cache *cache.Cache[string], setCacheFns ...SetCacheFn) *RequestBuilder
- func (r *RequestBuilder) WithTimeout(timeout time.Duration) *RequestBuilder
- type SetCacheFn
- type SetCacheTransport
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
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
func New ¶
func New(method, url string) *RequestBuilder
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 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
Click to show internal directories.
Click to hide internal directories.