Documentation
¶
Index ¶
- Variables
- func BuildRequest(method string, urlstr string, body io.Reader, opts *Opts) (*http.Request, error)
- func Q(kv ...string) url.Values
- type Opts
- type Resp
- func Do(method string, url string, body io.Reader, opts *Opts) *Resp
- func Get(url string) *Resp
- func Get2(url string, opts *Opts) *Resp
- func Post2(url string, body io.Reader, opts *Opts) *Resp
- func PostFiles(url string, files map[string]string) *Resp
- func PostFiles2(url string, files map[string]string, opts *Opts) *Resp
- func PostJSON(url string, body any) *Resp
Constants ¶
This section is empty.
Variables ¶
var ( DefaultTimeout = 5 * time.Second DefaultClient = &http.Client{Timeout: DefaultTimeout} )
Functions ¶
func BuildRequest ¶
BuildRequest 创建一个http请求, 合并opts中的参数到请求中, 返回请求对象和错误
Types ¶
type Opts ¶
type Resp ¶
Resp is the response of a request
func Get ¶
Get performs an HTTP GET request to the specified URL and returns a pointer to a Resp struct containing the response and any error encountered.
func Get2 ¶
Get2 performs an HTTP GET request to the specified URL with the given options and returns a pointer to a Resp struct containing the response and any error encountered.
func Post2 ¶
Post2 performs an HTTP POST request to the specified URL with the given body and options and returns a pointer to a Resp struct containing the response and any error encountered.
func PostFiles ¶
PostFiles performs an HTTP POST request to the specified URL with a multipart/form-data body and returns a pointer to a Resp struct containing the response and any error encountered. The files map is a map of field names and file paths. The file paths can start with "@" to indicate a file path.