http_client

package
v2.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOptions = func() Options {
		return Options{
			MaxIdleConns:        8,
			MaxIdleConnsPerHost: 2,
			MaxConnsPerHost:     8,
			TimeoutSec:          30,
			DialTimeoutSec:      30,
			IdleConnTimeoutSec:  60,
			KeepaliveSec:        60,
			WriteBufferSize:     4 << 10,
			ReadBufferSize:      4 << 10,
		}
	}
)

Functions

This section is empty.

Types

type Headers

type Headers map[string]string

type Options

type Options struct {
	MaxIdleConns        int  `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxIdleConnsPerHost int  `json:"maxIdleConnsPerHost" yaml:"maxIdleConnsPerHost"`
	MaxConnsPerHost     int  `json:"maxConnsPerHost" yaml:"maxConnsPerHost"`
	TimeoutSec          int  `json:"timeoutSec" yaml:"timeoutSec"`
	DialTimeoutSec      int  `json:"dialTimeoutSec" yaml:"dialTimeoutSec"`
	IdleConnTimeoutSec  int  `json:"idleConnTimeoutSec" yaml:"idleConnTimeoutSec"`
	DisableKeepAlives   bool `json:"disableKeepAlives" yaml:"disableKeepAlives"`
	DisableCompression  bool `json:"disableCompression" yaml:"disableCompression"`
	KeepaliveSec        int  `json:"keepaliveSec" yaml:"keepaliveSec"`
	WriteBufferSize     int  `json:"writeBufferSize" yaml:"writeBufferSize"`
	ReadBufferSize      int  `json:"readBufferSize" yaml:"readBufferSize"`
}

func (*Options) DialTimeout added in v2.0.9

func (o *Options) DialTimeout() time.Duration

func (*Options) IdleConnTimeout

func (o *Options) IdleConnTimeout() time.Duration

func (*Options) KeepaliveTime added in v2.0.9

func (o *Options) KeepaliveTime() time.Duration

func (*Options) Timeout

func (o *Options) Timeout() time.Duration

type Pool added in v2.0.9

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

func NewPool added in v2.0.9

func NewPool(opt Options) *Pool

func (*Pool) Delete added in v2.0.9

func (c *Pool) Delete(ctx context.Context, url string, headers Headers) (rp *Response, err error)

func (*Pool) DeleteTimeout added in v2.0.9

func (c *Pool) DeleteTimeout(timeout time.Duration, url string, headers Headers) (rp *Response, err error)

func (*Pool) Do added in v2.0.9

func (c *Pool) Do(req *http.Request) (rp *Response, err error)

func (*Pool) Get added in v2.0.9

func (c *Pool) Get(ctx context.Context, url string, headers Headers) (rp *Response, err error)

func (*Pool) GetTimeout added in v2.0.9

func (c *Pool) GetTimeout(timeout time.Duration, url string, headers Headers) (rp *Response, err error)

func (*Pool) Head added in v2.0.9

func (c *Pool) Head(ctx context.Context, url string, headers Headers) (rp *Response, err error)

func (*Pool) HeadTimeout added in v2.0.9

func (c *Pool) HeadTimeout(timeout time.Duration, url string, headers Headers) (rp *Response, err error)

func (*Pool) Options added in v2.0.9

func (c *Pool) Options(ctx context.Context, url string, headers Headers) (rp *Response, err error)

func (*Pool) OptionsTimeout added in v2.0.9

func (c *Pool) OptionsTimeout(timeout time.Duration, url string, headers Headers) (rp *Response, err error)

func (*Pool) Post added in v2.0.9

func (c *Pool) Post(ctx context.Context, url string, body []byte, headers Headers) (rp *Response, err error)

func (*Pool) PostTimeout added in v2.0.9

func (c *Pool) PostTimeout(timeout time.Duration, url string, body []byte, headers Headers) (rp *Response, err error)

func (*Pool) Put added in v2.0.9

func (c *Pool) Put(ctx context.Context, url string, body []byte, headers Headers) (rp *Response, err error)

func (*Pool) PutTimeout added in v2.0.9

func (c *Pool) PutTimeout(timeout time.Duration, url string, body []byte, headers Headers) (rp *Response, err error)

func (*Pool) Request added in v2.0.9

func (c *Pool) Request(ctx context.Context, method, url string, body []byte, headers Headers) (rp *Response, err error)

func (*Pool) RequestTimeout added in v2.0.9

func (c *Pool) RequestTimeout(timeout time.Duration, method, url string, body []byte, headers Headers) (rp *Response, err error)

type Response

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

func NewResp

func NewResp(status int) *Response

func (*Response) GetBody

func (rp *Response) GetBody() []byte

func (*Response) GetStatus

func (rp *Response) GetStatus() int

func (*Response) Is

func (rp *Response) Is(status int) bool

func (*Response) SetBody

func (rp *Response) SetBody(body []byte) *Response

func (*Response) UnmarshalJson

func (rp *Response) UnmarshalJson(out any) error

Jump to

Keyboard shortcuts

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