http_utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 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 HTTPClient

type HTTPClient struct {
	Client *http.Client
}

func NewHTTPClient

func NewHTTPClient() *HTTPClient

func (*HTTPClient) DownloadFile added in v1.0.8

func (c *HTTPClient) DownloadFile(r *HTTPRequest, filepath string) error

DownloadFile 发送HTTP请求并将响应数据保存为文件

func (*HTTPClient) SendRequest

func (c *HTTPClient) SendRequest(r *HTTPRequest) ([]byte, error)

SendRequest 发送HTTP请求并读取响应数据

func (*HTTPClient) SetProxy added in v1.0.8

func (c *HTTPClient) SetProxy(proxyFunc func(req *http.Request) (*url.URL, error))

func (*HTTPClient) SetTimeout added in v1.0.8

func (c *HTTPClient) SetTimeout(timeout time.Duration)

type HTTPRequest

type HTTPRequest struct {
	Method      string
	APIUrl      string
	Query       map[string]string
	Header      map[string]string
	ContentType string
	Body        any
}

HTTPRequest 包含apiUrl和headers

func NewHTTPRequest

func NewHTTPRequest(method, apiUrl string, query, header map[string]string, contentType string, body any) *HTTPRequest

Jump to

Keyboard shortcuts

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