Documentation ¶
Index ¶
- func Get(url string, opts ...RequestOption) (resp *http.Response, err error)
- func PostForm(url string, data url.Values, opts ...RequestOption) (resp *http.Response, err error)
- func PostFormFiles(url string, data url.Values, files []*UploadFile, opts ...RequestOption) (resp *http.Response, err error)
- func PostJSON(url string, body any, opts ...RequestOption) (resp *http.Response, err error)
- func ReadAll(resp *http.Response) (b []byte, err error)
- func ReadAnyJSON(resp *http.Response, v any) (err error)
- func ReadJSON[T any](resp *http.Response) (T, error)
- func ReadString(resp *http.Response) (s string, err error)
- func SaveFile(resp *http.Response, name string) (written int64, err error)
- func WithContentType(contentType string) func(*RequestOptions)
- func WithDialTimeout(dialTimeout time.Duration) func(*ClientOptions)
- func WithExpectContinueTimeout(expectContinueTimeout time.Duration) func(*ClientOptions)
- func WithHeaders(headers http.Header) func(*RequestOptions)
- func WithIdleConnTimeout(idleConnTimeout time.Duration) func(*ClientOptions)
- func WithKeepAliveTimeout(keepAliveTimeout time.Duration) func(*ClientOptions)
- func WithMaxIdleConns(maxIdleConns int) func(*ClientOptions)
- func WithProxy(proxy string) func(*ClientOptions)
- func WithReferer(referer string) func(*RequestOptions)
- func WithRequestTimeout(timeout time.Duration) func(*RequestOptions)
- func WithTLSHandshakeTimeout(tlsHandshakeTimeout time.Duration) func(*ClientOptions)
- func WithTimeout(timeout time.Duration) func(*ClientOptions)
- func WithUserAgent(userAgent string) func(*ClientOptions)
- type Client
- func (c *Client) Close()
- func (c *Client) Do(req *http.Request, opts ...RequestOption) (resp *http.Response, err error)
- func (c *Client) Get(url string, opts ...RequestOption) (resp *http.Response, err error)
- func (c *Client) Post(url string, contentType string, body io.Reader, opts ...RequestOption) (resp *http.Response, err error)
- func (c *Client) PostForm(url string, data url.Values, opts ...RequestOption) (resp *http.Response, err error)
- func (c *Client) PostFormFiles(url string, data url.Values, files []*UploadFile, opts ...RequestOption) (resp *http.Response, err error)
- func (c *Client) PostJSON(url string, body any, opts ...RequestOption) (resp *http.Response, err error)
- type ClientOption
- type ClientOptions
- type RequestOption
- type RequestOptions
- type UploadFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PostFormFiles ¶
func PostFormFiles(url string, data url.Values, files []*UploadFile, opts ...RequestOption) (resp *http.Response, err error)
PostFormFiles post form files
func ReadAnyJSON ¶
ReadAnyJSON read json from resp.Body
func ReadString ¶
ReadString read string from resp.Body and auto convert encoding
func WithContentType ¶
func WithContentType(contentType string) func(*RequestOptions)
func WithDialTimeout ¶
func WithDialTimeout(dialTimeout time.Duration) func(*ClientOptions)
func WithExpectContinueTimeout ¶
func WithExpectContinueTimeout(expectContinueTimeout time.Duration) func(*ClientOptions)
func WithHeaders ¶
func WithHeaders(headers http.Header) func(*RequestOptions)
func WithIdleConnTimeout ¶
func WithIdleConnTimeout(idleConnTimeout time.Duration) func(*ClientOptions)
func WithKeepAliveTimeout ¶
func WithKeepAliveTimeout(keepAliveTimeout time.Duration) func(*ClientOptions)
func WithMaxIdleConns ¶
func WithMaxIdleConns(maxIdleConns int) func(*ClientOptions)
func WithProxy ¶
func WithProxy(proxy string) func(*ClientOptions)
func WithReferer ¶
func WithReferer(referer string) func(*RequestOptions)
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) func(*RequestOptions)
func WithTLSHandshakeTimeout ¶
func WithTLSHandshakeTimeout(tlsHandshakeTimeout time.Duration) func(*ClientOptions)
func WithTimeout ¶
func WithTimeout(timeout time.Duration) func(*ClientOptions)
func WithUserAgent ¶
func WithUserAgent(userAgent string) func(*ClientOptions)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(ctx context.Context, opts ...ClientOption) *Client
NewClient new client
func (*Client) Post ¶
func (c *Client) Post(url string, contentType string, body io.Reader, opts ...RequestOption) (resp *http.Response, err error)
Post post
func (*Client) PostForm ¶
func (c *Client) PostForm(url string, data url.Values, opts ...RequestOption) (resp *http.Response, err error)
PostForm post form
func (*Client) PostFormFiles ¶
func (c *Client) PostFormFiles(url string, data url.Values, files []*UploadFile, opts ...RequestOption) (resp *http.Response, err error)
PostFormFiles post form files
type ClientOption ¶
type ClientOption func(*ClientOptions)
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
ClientOptions http client options
type RequestOption ¶
type RequestOption func(*RequestOptions)
type RequestOptions ¶
type RequestOptions struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.