xhttp

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode added in v0.0.5

func Encode(body interface{}) []byte

Encode ...

func Get

func Get(ctx context.Context, url string) string

Get ...

func GetDecompressBody added in v0.0.5

func GetDecompressBody(compressType string, body io.ReadCloser) (io.ReadCloser, error)

GetDecompressBody ...

func Post

func Post(ctx context.Context, url string, body interface{}) string

Post ...

func ToBytes

func ToBytes(res *http.Response, err error) []byte

ToBytes ...

func ToString

func ToString(res *http.Response, err error) string

ToString ...

Types

type Client added in v0.0.5

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client ...

func New added in v0.0.5

func New() *Client

New ...

func NewWithtions added in v0.0.5

func NewWithtions(option *Option) *Client

NewWithtions ...

func (*Client) Delete added in v0.0.5

func (t *Client) Delete(
	ctx context.Context,
	url string,
	headers http.Header,
) (*http.Response, error)

Delete ...

func (*Client) Do added in v0.0.5

func (t *Client) Do(
	ctx context.Context,
	method string,
	url string,
	headers http.Header,
	body []byte,
) (*http.Response, error)

Do ...

func (*Client) Get added in v0.0.5

func (t *Client) Get(
	ctx context.Context,
	url string,
	headers http.Header,
) (*http.Response, error)

Get ...

func (*Client) Post added in v0.0.5

func (t *Client) Post(
	ctx context.Context,
	url string,
	headers http.Header,
	body []byte,
) (*http.Response, error)

Post ...

func (*Client) Put added in v0.0.5

func (t *Client) Put(
	ctx context.Context,
	url string,
	headers http.Header,
	body []byte,
) (*http.Response, error)

Put ...

type Option

type Option struct {
	SSLEnabled            bool
	TLSConfig             *tls.Config
	Compressed            bool
	HandshakeTimeout      time.Duration
	ResponseHeaderTimeout time.Duration
	RequestTimeout        time.Duration
	ConnsPerHost          int
	RetryTimes            int
}

Option ...

Jump to

Keyboard shortcuts

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