Documentation
¶
Index ¶
- func FileDownload(url, filePath string) error
- func FileDownloadWithProgress(url string, filePath string, callback DownloadProgressCallback) error
- func HttpDelete(url string, header ...byte) ([]byte, error)
- func HttpDeleteWithTimeout(url string, timeout time.Duration, header ...byte) ([]byte, error)
- func HttpGet(url string, header ...byte) ([]byte, error)
- func HttpGetWithTimeout(url string, timeout time.Duration, header ...byte) ([]byte, error)
- func HttpPost(url string, data any, header ...byte) ([]byte, error)
- func HttpPostWithTimeout(url string, data any, timeout time.Duration, header ...byte) ([]byte, error)
- func HttpPut(url string, data any, header ...byte) ([]byte, error)
- func HttpPutWithTimeout(url string, data any, timeout time.Duration, header ...byte) ([]byte, error)
- func Ipv4sLocal() ([]string, error)
- func ParseResponse[T any](respBytes []byte, err error) (T, error)
- func ShouldBindJson(req *http.Request, data any) error
- func ShouldBindQuery(req *http.Request, data any) error
- func UrlBase(rawURL string) string
- type DownloadProgress
- type DownloadProgressCallback
- type Mail
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileDownloadWithProgress ¶
func FileDownloadWithProgress(url string, filePath string, callback DownloadProgressCallback) error
FileDownloadWithProgress 带进度的文件下载
Params: ¶
url: 文件地址 filePath: 文件路径 callback: 用于通知下载进度
func HttpDeleteWithTimeout ¶
HttpDeleteWithTimeout http delete 请求带超时时长
Params: ¶
url: 请求地址 timeout: 超时时间 header: 请求头
func HttpGetWithTimeout ¶
HttpGetWithTimeout http get 请求
Params: ¶
url: 请求地址 timeout: 超时时间 header: 请求头
func HttpPostWithTimeout ¶
func HttpPostWithTimeout(url string, data any, timeout time.Duration, header ...byte) ([]byte, error)
HttpPostWithTimeout http post 请求
Params: ¶
url: 请求地址 data: 请求参数 timeout: 超时时间 header: 请求头
func HttpPutWithTimeout ¶
func HttpPutWithTimeout(url string, data any, timeout time.Duration, header ...byte) ([]byte, error)
HttpPutWithTimeout http put 请求
Params: ¶
url: 请求地址 data: 请求参数 timeout: 超时时间 header: 请求头
Types ¶
type DownloadProgress ¶
type DownloadProgress struct {
Total int64 // 文件总大小
Finish int64 // 当前已写入大小
// contains filtered or unexported fields
}
DownloadProgress 包装了一个 io.Writer,并加入了进度回调功能。
func FileDownloadWithNotify ¶
func FileDownloadWithNotify(ch chan DownloadProgress, url, filePath string) (*DownloadProgress, error)
FileDownloadWithNotify 带通知的文件下载
Params: ¶
ch: 通知进度 url: 文件地址 filePath: 文件路径
type DownloadProgressCallback ¶
type DownloadProgressCallback func(finishBytes, totalBytes int64)
Click to show internal directories.
Click to hide internal directories.