http

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Http

type Http struct {
	Url    string
	Client *http.Client
	// contains filtered or unexported fields
}

Http HTTP请求客户端

func NewHttp

func NewHttp(url string) *Http

func (*Http) ClearDefaultHeaders

func (h *Http) ClearDefaultHeaders() *Http

ClearDefaultHeaders 清除默认请求头

func (*Http) Do

func (h *Http) Do(urlPath string, method string, headers map[string]string, body io.Reader) ([]byte, error)

Do 执行HTTP请求

func (*Http) Get

func (h *Http) Get(params url.Values, result any) error

Get 执行GET请求

func (*Http) PostForm

func (h *Http) PostForm(formData url.Values, result any) error

PostForm 发送表单数据

func (*Http) PostJSON

func (h *Http) PostJSON(jsonData any, result any) error

PostJSON 发送JSON数据

func (*Http) PostMultipart

func (h *Http) PostMultipart(formBuilder func(w *multipart.Writer) error, result any) error

PostMultipart 发送 multipart/form-data 请求

func (*Http) SetHeader

func (h *Http) SetHeader(key, value string) *Http

SetHeader 设置默认请求头

func (*Http) SetTimeout

func (h *Http) SetTimeout(timeout time.Duration) *Http

SetTimeout 设置超时时间

Jump to

Keyboard shortcuts

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