http_client

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 8 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,
			IdleConnTimeoutSec:  60,
			WriteBufferSize:     4 << 10,
			ReadBufferSize:      4 << 10,
		}
	}
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opt Options) *Client

func (*Client) Delete

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

func (*Client) DeleteTimeout

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

func (*Client) Do

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

func (*Client) Get

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

func (*Client) GetTimeout

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

func (*Client) Head

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

func (*Client) HeadTimeout

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

func (*Client) Options

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

func (*Client) OptionsTimeout

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

func (*Client) Post

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

func (*Client) PostTimeout

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

func (*Client) Put

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

func (*Client) PutTimeout

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

func (*Client) Request

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

func (*Client) RequestTimeout

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

type Headers

type Headers map[string]string

type Options

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

func (*Options) IdleConnTimeout

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

func (*Options) Timeout

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

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