http

package
v0.0.0-...-97c6c0c Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is http client.

func NewClient

func NewClient(c *ClientConfig) *Client

NewClient new a http client.

func (*Client) Do

func (client *Client) Do(c context.Context, req *xhttp.Request) (res []byte, resp *xhttp.Response, err error)

Do sends an HTTP request and returns

func (*Client) Get

func (client *Client) Get(c context.Context, uri string, headers xhttp.Header) ([]byte, *xhttp.Response, error)

Get issues a GET to the specified URL.

func (*Client) JSON

func (client *Client) JSON(c context.Context, req *xhttp.Request, res interface{}) (resp *xhttp.Response, err error)

JSON sends an HTTP request and returns an HTTP json response.

func (*Client) NewRequest

func (client *Client) NewRequest(method, uri string, values url.Values, headers xhttp.Header) (req *xhttp.Request, err error)

NewRequest new http request with method, uri, ip, values and headers.

func (*Client) Post

func (client *Client) Post(c context.Context, uri string, values url.Values, headers xhttp.Header) ([]byte, *xhttp.Response, error)

Post issues a POST to the specified URL.

func (*Client) Raw

func (client *Client) Raw(c context.Context, req *xhttp.Request) (bs []byte, resp *xhttp.Response, err error)

Raw sends an HTTP request and returns bytes response

func (*Client) SetConfig

func (client *Client) SetConfig(c *ClientConfig)

SetConfig set client config.

func (*Client) SetProxy

func (client *Client) SetProxy(proxyURL string)

SetProxy set client proxy.

type ClientConfig

type ClientConfig struct {
	Dial          time.Duration
	Timeout       time.Duration
	KeepAlive     time.Duration
	ProxyURL      string
	CheckRedirect func(req *xhttp.Request, via []*xhttp.Request) error
}

ClientConfig is http client conf.

Jump to

Keyboard shortcuts

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