httpx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResponseErrLimit int64 = 1024

Functions

func AddSomeResponse

func AddSomeResponse(resp *http.Response) []byte

AddSomeResponse not close body, retry library draining it.

func RetryPolicy

func RetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

RetryPolicy provides a default callback for Client.CheckRetry, which will retry on connection errors and server errors.

Types

type Client

type Client struct {
	HTTPClient *http.Client
}

func New

func New(opts ...Option) *Client

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, url, method string, headers map[string]interface{}, payload []byte) (*http.Request, error)

NewRequest creates a new HTTP request with the given method, URL, and optional body.

func (*Client) Send

func (c *Client) Send(
	ctx context.Context,
	url, method string,
	headers map[string]interface{},
	payload []byte,
	retry *Retry,
) (*ClientResponse, error)

type ClientResponse

type ClientResponse struct {
	Header     http.Header
	Body       []byte
	StatusCode int
}

type Option

type Option func(options *options)

func WithBackoff

func WithBackoff(backoff retryablehttp.Backoff) Option

func WithLog

func WithLog(log retryablehttp.LeveledLogger) Option

func WithPooled

func WithPooled(pooled bool) Option

func WithRetryMax

func WithRetryMax(retryMax int) Option

func WithRetryPolicy

func WithRetryPolicy(retryPolicy retryablehttp.CheckRetry) Option

func WithRetryWaitMax

func WithRetryWaitMax(retryWaitMax time.Duration) Option

func WithRetryWaitMin

func WithRetryWaitMin(retryWaitMin time.Duration) Option

func WithSkipVerify

func WithSkipVerify(skip bool) Option

type Retry

type Retry struct {
	DisableRetry        bool
	DisabledStatusCodes []int
	EnabledStatusCodes  []int
}

type RetryCodesType

type RetryCodesType string
const RetryCodesValue RetryCodesType = "retryCodeValue"

Jump to

Keyboard shortcuts

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