httpx

package
v1.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseQuery

func ParseQuery(qr map[string]any) string

ParseQuery 处理结构体转为query参数

Types

type HTTPX

type HTTPX struct {
	http.Client
	// contains filtered or unexported fields
}

HTTPX http请求封装

func NewHTTPX

func NewHTTPX() *HTTPX

NewHTTPX 创建一个http请求

func (*HTTPX) GET

func (h *HTTPX) GET(u string) (*http.Response, error)

GET 发起get请求

func (*HTTPX) GETWithContext

func (h *HTTPX) GETWithContext(ctx context.Context, u string) (*http.Response, error)

GETWithContext 发起get请求

func (*HTTPX) POST

func (h *HTTPX) POST(url string, data []byte) (*http.Response, error)

POST 发起post请求

func (*HTTPX) POSTWithContext

func (h *HTTPX) POSTWithContext(ctx context.Context, url string, data []byte) (*http.Response, error)

POSTWithContext 发起post请求

func (*HTTPX) SetBasicAuth

func (h *HTTPX) SetBasicAuth(username, password string) *HTTPX

SetBasicAuth 将用户名和密码添加到请求头中

req.SetBasicAuth(username, password)

func (*HTTPX) SetHeader

func (h *HTTPX) SetHeader(headers map[string]string) *HTTPX

SetHeader 设置请求头

Jump to

Keyboard shortcuts

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