Documentation
¶
Index ¶
- Variables
- func DebugDialer(ctx context.Context, network, addr string) (net.Conn, error)
- func MakeRequest(opts ...ReqOpt) (*http.Request, error)
- type Body
- type BodyOpt
- type Client
- func (c *Client) Close()
- func (c *Client) Do(req *http.Request) (resp *http.Response, err error)
- func (c *Client) DoRequest(ctx context.Context, req *http.Request) (resp *http.Response, err error)
- func (c *Client) Execute(ctx context.Context, req *http.Request, processor ResponseProcessor) error
- func (c *Client) GetClient() *http.Client
- func (c *Client) GetTransport() http.RoundTripper
- type DialContext
- type DumpResponse
- type DumpResponseOpt
- type Opt
- func Debug(flag bool) Opt
- func Dialer(dialer DialContext) Opt
- func ExecuteRetry(retry int) Opt
- func HTTPClient(client *http.Client) Opt
- func Keepalive(keepalive time.Duration) Opt
- func MaxConnsPerHost(max int) Opt
- func MaxIdleConnsPerHost(max int) Opt
- func Proxy(host string) Opt
- func Retry(retry int) Opt
- func TLSConfig(cred *tls.Config) Opt
- func Timeout(duration time.Duration) Opt
- func Transport(transport http.RoundTripper) Opt
- type ReqOpt
- func BasicAuth(username string, password string) ReqOpt
- func BearerAuth(token string) ReqOpt
- func BearerAuthFunc(token TokenFunc) ReqOpt
- func Content(opts ...BodyOpt) ReqOpt
- func Cookie(cookie *http.Cookie) ReqOpt
- func Header(name string, value string) ReqOpt
- func Method(method string) ReqOpt
- func Query(name string, value string) ReqOpt
- func SetURL(Url string) ReqOpt
- func URL(opts ...URLOpt) ReqOpt
- type RequestBuilder
- type ResponseProcessor
- type ResponseProcessorFunc
- type TokenFunc
- type URLOpt
Constants ¶
This section is empty.
Variables ¶
var ( //DefaultMaxConnsPerHost default max connections for per host DefaultMaxConnsPerHost = 32 //DefaultMaxIdleConnsPerHost default max idle connections for per host DefaultMaxIdleConnsPerHost = 8 //DefaultClientTimeout default client timeout for each do request DefaultClientTimeout = 30 * time.Second //DefaultTLSHandhakeTimeout default client tls hands hake timeout DefaultTLSHandhakeTimeout = 10 * time.Second )
var DefaultTLSConfig *tls.Config
DefaultTLSConfig default tls.config is nil
Functions ¶
func DebugDialer ¶ added in v0.2.0
DebugDialer debug dialer
Types ¶
type Client ¶
Client struct
func (*Client) Close ¶ added in v0.2.0
func (c *Client) Close()
Close Client release connection resource
func (*Client) GetTransport ¶ added in v0.2.1
func (c *Client) GetTransport() http.RoundTripper
GetTransport get standard http.RoundTripper Transport
type DialContext ¶ added in v0.2.0
DialContext dialer function
type DumpResponse ¶
type DumpResponse struct {
// contains filtered or unexported fields
}
DumpResponse struct
func NewDumpResponse ¶
func NewDumpResponse(opts ...DumpResponseOpt) *DumpResponse
NewDumpResponse new
type DumpResponseOpt ¶ added in v0.2.0
type DumpResponseOpt func(*DumpResponse)
DumpResponseOpt option
type Opt ¶
type Opt func(*config)
Opt for client
func ExecuteRetry ¶ added in v0.2.0
ExecuteRetry opt for client.Execute, only > 1
func HTTPClient ¶ added in v0.2.1
HTTPClient opt, when this option is SET, All above option will ignore
func MaxIdleConnsPerHost ¶ added in v0.2.0
MaxIdleConnsPerHost opt
func Transport ¶
func Transport(transport http.RoundTripper) Opt
Transport opt, When this option is SET, Timeout/MaxConnsPerHost/MaxIdleConnsPerHost option will be IGNORED!!!
type ReqOpt ¶
type ReqOpt func(*requestConfig)
ReqOpt opt
func BearerAuthFunc ¶ added in v0.4.3
BearerAuthFunc opt
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
RequestBuilder struct
func NewRequestBuilder ¶
func NewRequestBuilder(opts ...ReqOpt) *RequestBuilder
NewRequestBuilder new
type ResponseProcessor ¶
ResponseProcessor interface
type ResponseProcessorFunc ¶ added in v0.2.0
ResponseProcessorFunc type
type URLOpt ¶ added in v0.3.0
func UserPassword ¶ added in v0.3.0
UserPassword opt