httpclient

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{Timeout: time.Second * time.Duration(30)}

DefaultClient 默认http client

Functions

func BuildURLWithArray

func BuildURLWithArray(url string, params [][]string) string

BuildURLWithArray 使用二维数组结构构件url请求参数 [[key,value], ...] => /url/xxx?key=value

func BuildURLWithMap

func BuildURLWithMap(url string, params map[string]string) string

BuildURLWithMap 使用Map结构构件url请求参数 {key:value} => /url/xxx?key=value

func DoRequest

func DoRequest(client *http.Client, method, contentType, url string, content io.Reader, header map[string]string) (*http.Response, error)

DoRequest 发送请求(client, 请求方式, Content-Type, url)

func DoUploadFile

func DoUploadFile(client *http.Client, method, url string, reader io.Reader, headers map[string]string, fieldname, filename string) (*http.Response, error)

DoUploadFile 上传文件文件 form-data

func Get

func Get(url string, params map[string]string, headers map[string]string) (*http.Response, error)

Get Get请求

func Post

func Post(url string, params map[string]string, headers map[string]string) (*http.Response, error)

Post Post请求

func PostFile

func PostFile(url, filePath string, headers map[string]string) (*http.Response, error)

PostFile 发送文件使用默认的file表单字段

func PostJSON

func PostJSON(client *http.Client, method, url string, params interface{}, headers map[string]string) (*http.Response, error)

PostJSON 通过Post Json 内容发送请求

func PutFile

func PutFile(url, filePath string, headers map[string]string) (*http.Response, error)

PostFile 发送文件使用默认的file表单字段

func Request4JSON

func Request4JSON(client *http.Client, method, url string, params interface{}, headers map[string]string) (*http.Response, error)

Request4JSON 通过 Json 内容发送请求

func Request4URL

func Request4URL(client *http.Client, method, url string, params, headers map[string]string) (*http.Response, error)

Request4URL 发送请求, 认使用 application/x-www-form-urlencoded 方式发送请求

Types

This section is empty.

Jump to

Keyboard shortcuts

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