request

package
v1.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(url string, options ...Option) (code int, respBuf []byte, respHeader map[string][]string, err error)

DoRequest exec https? request and return []byte

func DoRequestUndercourse

func DoRequestUndercourse(url string, options ...Option) (resp *http.Response, err error)

DoRequestUndercourse exec https? request and return response

Types

type Option

type Option func(*Options)

Option request option

func WithClient added in v1.9.6

func WithClient(client *http.Client) Option

WithClient use custom http.Client

client will invalidate WithSSL, WithTimeout, WithProxy

func WithContext

func WithContext(ctx context.Context) Option

WithContext set context.

func WithData

func WithData(data []byte) Option

WithData set request data.

func WithHeader

func WithHeader(header map[string]string) Option

WithHeader set request header.

func WithMethod

func WithMethod(method string) Option

WithMethod set request method.

func WithOptions

func WithOptions(options Options) Option

WithOptions accepts the whole options config.

func WithProxy added in v1.9.6

func WithProxy(proxy string) Option

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

func WithProxyFn(fn func(*http.Request) (*url.URL, error)) Option

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.

func WithSSL

func WithSSL(ssl bool) Option

WithSSL set request skip ssl verify.

func WithTimeout

func WithTimeout(timeout int) Option

WithTimeout set request timeout.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options request options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL