Versions in this module Expand all Collapse all v1 v1.0.1 Dec 4, 2023 Changes in this version + const HeaderKeyAccept + const HeaderKeyAcceptEncoding + const HeaderKeyAuthorization + const HeaderKeyContentEncoding + const HeaderKeyContentEncodingValueGzip + const HeaderKeyContentLength + const HeaderKeyContentType + const HeaderKeyContentTypeValueForm + const HeaderKeyContentTypeValueFormData + const HeaderKeyContentTypeValueJSON + const HeaderKeyLocation + const HeaderKeyUserAgent + const MethodDelete + const MethodGet + const MethodHead + const MethodOptions + const MethodPatch + const MethodPost + const MethodPut + var HeaderContentTypeForm = http.Header + var HeaderContentTypeFormData = http.Header + var HeaderContentTypeJSON = http.Header + func BuildFormData(header http.Header, m map[string]interface{}) (http.Header, io.Reader) + func BuildReader(data interface{}, types ...string) io.Reader + func BuildURL(url string, m map[string]interface{}) string + func BuildValues(m map[string]interface{}) url.Values + func Get(ctx context.Context, url string) string + func ParseQuery(str string) map[string]string + func ParseURL(str string) (*url.URL, error) + func Post(ctx context.Context, url string, data interface{}) string + func ToResponse(r *Response, err error) (*http.Response, error) + func ToString(r *Response, err error) string + type Client struct + func New(options ...OptionFn) *Client + func (t *Client) Delete(ctx context.Context, url string, header http.Header) (*Response, error) + func (t *Client) Do(ctx context.Context, method string, url string, header http.Header, ...) (*Response, error) + func (t *Client) Get(ctx context.Context, url string, header http.Header) (*Response, error) + func (t *Client) Patch(ctx context.Context, url string, header http.Header) (*Response, error) + func (t *Client) Post(ctx context.Context, url string, header http.Header, data interface{}) (*Response, error) + func (t *Client) Put(ctx context.Context, url string, header http.Header, data interface{}) (*Response, error) + type Option struct + Dialer *net.Dialer + RequestTimeout time.Duration + RetryTimes int + TraceEnable bool + Transport *http.Transport + type OptionFn func(*Option) + func WithDialer(v *net.Dialer) OptionFn + func WithRequestTimeout(v time.Duration) OptionFn + func WithRetryTimes(v int) OptionFn + func WithTraceEnable() OptionFn + func WithTransport(v *http.Transport) OptionFn + type Response struct + func (t *Response) Bytes() []byte + func (t *Response) String() string + func (t *Response) Trace() *Trace + type Trace struct + ConnIdleTime time.Duration + ConnTime time.Duration + DNSLookup time.Duration + IsConnReused bool + IsConnWasIdle bool + RemoteAddr net.Addr + RequestAttempt int + ResponseTime time.Duration + ServerTime time.Duration + TCPConnTime time.Duration + TLSHandshake time.Duration + TotalTime time.Duration + func (t *Trace) Finish() + func (t *Trace) WithClientTrace(ctx context.Context) context.Context