Documentation ¶
Index ¶
- func DoRequest(url string, options ...Option) (code int, respBuf []byte, respHeader map[string][]string, err error)
- func DoRequestUndercourse(url string, options ...Option) (resp *http.Response, err error)
- type Option
- func WithClient(client *http.Client) Option
- func WithContext(ctx context.Context) Option
- func WithData(data []byte) Option
- func WithHeader(header map[string]string) Option
- func WithMethod(method string) Option
- func WithOptions(options Options) Option
- func WithProxy(proxy string) Option
- func WithProxyFn(fn func(*http.Request) (*url.URL, error)) Option
- func WithSSL(ssl bool) Option
- func WithTimeout(timeout int) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
Option request option
func WithClient ¶ added in v1.9.6
WithClient use custom http.Client
client will invalidate WithSSL, WithTimeout, WithProxy
func WithOptions ¶
WithOptions accepts the whole options config.
func WithProxy ¶ added in v1.9.6
WithProxy specifies a function to return a proxy for a given Request. If the function returns a non-nil error, the request is aborted with the provided error.
The proxy type is determined by the URL scheme. "http", "https", and "socks5" are supported. If the scheme is empty, "http" is assumed.
If Proxy is nil or returns a nil *URL, no proxy is used.
func WithProxyFn ¶ added in v1.9.6
WithProxyFn specifies a function to return a proxy for a given Request. If the function returns a non-nil error, the request is aborted with the provided error.
The proxy type is determined by the URL scheme. "http", "https", and "socks5" are supported. If the scheme is empty, "http" is assumed.
If Proxy is nil or returns a nil *URL, no proxy is used.