Documentation ¶
Index ¶
- Constants
- func Get(url string, options ...Option) (int, []byte, error)
- func GetForResponse(url string, options ...Option) (*http.Response, error)
- func IsCodeValid(code int) bool
- func Post(url string, options ...Option) (int, []byte, error)
- func PostForResponse(url string, options ...Option) (*http.Response, error)
- func Upload(url string, fileParams map[string]string, options ...Option) (int, []byte, error)
- func UploadForResponse(url string, fileParams map[string]string, options ...Option) (*http.Response, error)
- type Option
Constants ¶
View Source
const ( // DefaultTimeout 发送请求的默认超时时间. DefaultTimeout = time.Second * 10 )
Variables ¶
This section is empty.
Functions ¶
func IsCodeValid ¶
IsCodeValid 响应的http状态码 是否有效?
PS: (1) 判断参考了jQuery; (2) 正常情况下,响应的http状态码有效的情况下,才会去读取响应的body.
func PostForResponse ¶
PostForResponse
!!!: 第2个返回值 == nil 的情况下,需要手动调用 resp.Body.Close() 来手动关闭 第1个返回值.
Types ¶
type Option ¶
type Option func(opts *options)
Click to show internal directories.
Click to hide internal directories.