Documentation ¶
Index ¶
- func DoRequest(request_url string, options ...Option) (code int, respBuf []byte, respHeader map[string][]string, err error)
- func DoRequestUndercourse(request_url string, options ...Option) (resp *http.Response, err error)
- func NewHttpClient(opts *Options) (client_http *http.Client)
- type Option
- func WithClient(client *http.Client) Option
- func WithContext(ctx context.Context) Option
- func WithData(data []byte) Option
- func WithHTTP2(http2 bool) Option
- func WithHeader(header map[string]string) Option
- func WithMethod(method string) Option
- func WithOptions(options Options) Option
- func WithParams(params map[string]string) 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 ¶
func DoRequest ¶
func DoRequest(request_url string, options ...Option) (code int, respBuf []byte, respHeader map[string][]string, err error)
DoRequest exec https? request and return []byte
func DoRequestUndercourse ¶
DoRequestUndercourse exec https? request and return response
func NewHttpClient ¶ added in v1.14.6
生成HttpClient对象
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 WithParams ¶ added in v1.14.7
WithParams set request url params.
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.