netx

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v1.0.7

func Close(resp *http.Response)

func Decode added in v1.0.7

func Decode(resp *http.Response, output any) error

func GetBody added in v1.0.7

func GetBody(resp *http.Response) ([]byte, error)

func IsValidHttpUrl

func IsValidHttpUrl(url string) bool

func JoinUrl added in v1.0.23

func JoinUrl(baseUrl, relativeUrl string) (string, error)

JoinUrl 将基准 Url 和相对 Url 拼接在一起,返回完整的 Url

func NewHttpTransport

func NewHttpTransport(proxyUrl string) (*http.Transport, error)

Types

type HttpRequestParams added in v1.0.23

type HttpRequestParams struct {
	Ctx             context.Context // 上下文
	Method          string          // 请求方法
	Url             string          // 请求地址
	Params          url.Values      // 请求参数
	FormData        url.Values      // 请求表单
	Body            any             // 请求体, io.Reader、[]byte、string、map、struct
	Header          http.Header     // 请求头
	Cookie          string          // Cookie
	Ua              string          // UserAgent
	Referer         string          // Referer
	ContentType     string          // Content-Type
	Proxy           string          // 代理, 如 http://127.0.0.1:7890、socks5://127.0.0.1:7891、sock5h://127.0.0.1:7892
	Timeout         time.Duration   // 超时
	MaxIdleConn     int             // 最大空闲连接
	IdleConnTimeout time.Duration   // 空闲连接超时
}

type Httpx

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

func NewHttpx

func NewHttpx(params HttpRequestParams) *Httpx

func (*Httpx) Body added in v1.0.23

func (h *Httpx) Body() ([]byte, *http.Response, error)

func (*Httpx) Decode

func (h *Httpx) Decode(output any) (*http.Response, error)

func (*Httpx) NewClient added in v1.0.23

func (h *Httpx) NewClient() (*http.Client, error)

func (*Httpx) NewRequest added in v1.0.23

func (h *Httpx) NewRequest() (req *http.Request, err error)

func (*Httpx) Request

func (h *Httpx) Request() (*http.Response, error)

Jump to

Keyboard shortcuts

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