Documentation ¶
Index ¶
- Variables
- type Auth
- type Config
- type Datas
- type Files
- type Header
- type JsonData
- type JsonString
- type Params
- type Request
- func (req *Request) Any(method, originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) ClearCookies()
- func (req *Request) ClientSetCookies()
- func (req *Request) Close()
- func (req *Request) Delete(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) Get(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) Patch(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) Post(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) Proxy(proxyUrl string) error
- func (req *Request) Put(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func (req *Request) SetCookie(cookie *http.Cookie)
- func (req *Request) SetTimeout(n time.Duration)
- type Requests
- func (r *Requests) AnyJsonWithTimeout(method string, targetUrl string, body map[string]interface{}, timeout int) (result string, err error)
- func (r *Requests) Delete(url string, args ...interface{}) (*Response, error)
- func (r *Requests) DeleteIgnoreParseError(url string, args ...interface{}) (*Response, error)
- func (r *Requests) Download(urlPath string, savePath string) error
- func (r *Requests) DownloadToBytes(urlPath string) ([]byte, error)
- func (r *Requests) Get(url string, args ...interface{}) (*Response, error)
- func (r *Requests) GetIgnoreParseError(url string, args ...interface{}) (*Response, error)
- func (r *Requests) Patch(url string, args ...interface{}) (*Response, error)
- func (r *Requests) PatchIgnoreParseError(url string, args ...interface{}) (*Response, error)
- func (r *Requests) Post(url string, args ...interface{}) (*Response, error)
- func (r *Requests) PostIgnoreParseError(url string, args ...interface{}) (*Response, error)
- func (r *Requests) PostJsonWithTimeout(targetUrl string, body map[string]interface{}, timeout int) (result string, err error)
- func (r *Requests) Put(url string, args ...interface{}) (*Response, error)
- func (r *Requests) PutIgnoreParseError(url string, args ...interface{}) (*Response, error)
- func (r *Requests) SetProxy(proxyUrl string) error
- func (r *Requests) Upload(targetUrl string, filePath string) error
- func (r *Requests) UploadByBytes(targetUrl string, formName string, filePath string, content []byte) ([]byte, error)
- func (r *Requests) UploadFsToBytes(targetUrl string, fsObj fs.FS, fileFormName, filePath string) (result []byte, err error)
- func (r *Requests) UploadFsToString(targetUrl string, fsObj fs.FS, fileFormName, filePath string) (result string, err error)
- func (r *Requests) UploadToBytes(targetUrl string, filePath string) ([]byte, error)
- func (r *Requests) UploadToResponse(targetUrl string, formName string, filePath string) (*http.Response, error)
- func (r *Requests) UploadToString(targetUrl string, filePath string) (string, error)
- type Response
- func Delete(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func Get(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func Patch(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func Post(url string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
- func Put(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Constants ¶
This section is empty.
Variables ¶
var VERSION string = "0.1.6" // 版本编号
Functions ¶
This section is empty.
Types ¶
type JsonString ¶ added in v0.2.5
type JsonString string // 提交JSON格式的字符串
type Request ¶ added in v0.2.5
type Request struct { Header *http.Header // 请求头 Client *http.Client // 请求客户端 Debug int // 是否为DEBUG模式 Cookies []*http.Cookie // cookie Config *Config // 配置对象 // contains filtered or unexported fields }
Request 请求对象
func NewRequestWithConfig ¶ added in v0.2.5
func (*Request) Any ¶ added in v0.2.5
func (req *Request) Any(method, originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Any 发送任意请求 @param originUrl 要请求的URL地址 @param args 请求携带的参数
func (*Request) ClearCookies ¶ added in v0.2.5
func (req *Request) ClearCookies()
ClearCookies 清除cookie
func (*Request) ClientSetCookies ¶ added in v0.2.5
func (req *Request) ClientSetCookies()
ClientSetCookies 客户端设置cookie
func (*Request) Delete ¶ added in v0.2.5
func (req *Request) Delete(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Delete 发送DELETE请求
func (*Request) Get ¶ added in v0.2.5
func (req *Request) Get(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Get 发送GET请求
func (*Request) Patch ¶ added in v0.2.5
func (req *Request) Patch(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Patch 发送PATCH请求
func (*Request) Post ¶ added in v0.2.5
func (req *Request) Post(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Post 发送POST请求 @param originUrl 要请求的URL地址 @param args 请求携带的参数
func (*Request) Put ¶ added in v0.2.5
func (req *Request) Put(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Put 发送PUT请求
func (*Request) SetTimeout ¶ added in v0.2.5
SetTimeout 设置客户端超时时间(秒)
type Requests ¶
type Requests struct {
Request *Request // 请求对象
}
func (*Requests) AnyJsonWithTimeout ¶ added in v0.2.7
func (r *Requests) AnyJsonWithTimeout(method string, targetUrl string, body map[string]interface{}, timeout int) (result string, err error)
AnyJsonWithTimeout 发送任意请求并携带JSON数据
func (*Requests) DeleteIgnoreParseError ¶ added in v0.1.5
DeleteIgnoreParseError 发送DELETE请求,且忽略解析URL时遇到的错误
func (*Requests) DownloadToBytes ¶ added in v0.2.2
DownloadToBytes 下载文件,返回文件流
func (*Requests) GetIgnoreParseError ¶ added in v0.1.2
GetIgnoreParseError 发送GET请求,且忽略解析URL时遇到的错误
func (*Requests) PatchIgnoreParseError ¶ added in v0.1.5
PatchIgnoreParseError 发送PATCH请求,且忽略解析URL时遇到的错误
func (*Requests) PostIgnoreParseError ¶ added in v0.1.2
PostIgnoreParseError 发送POST请求,且忽略解析URL时遇到的错误
func (*Requests) PostJsonWithTimeout ¶ added in v0.2.7
func (r *Requests) PostJsonWithTimeout(targetUrl string, body map[string]interface{}, timeout int) (result string, err error)
PostJsonWithTimeout 发送JSON请求并携带JSON数据
func (*Requests) PutIgnoreParseError ¶ added in v0.1.5
PutIgnoreParseError 发送PUT请求,且忽略解析URL时遇到的错误
func (*Requests) Upload ¶ added in v0.2.3
Upload 上传文件 @param targetUrl 目标地址 @param filePath 上传文件的路径 @return 错误对象
func (*Requests) UploadByBytes ¶ added in v0.2.6
func (r *Requests) UploadByBytes(targetUrl string, formName string, filePath string, content []byte) ([]byte, error)
UploadByBytes 根据字节数组上传文件
func (*Requests) UploadFsToBytes ¶ added in v0.2.4
func (r *Requests) UploadFsToBytes(targetUrl string, fsObj fs.FS, fileFormName, filePath string) (result []byte, err error)
UploadFsToBytes 上传FS文件系统的文件,返回bytes数据
func (*Requests) UploadFsToString ¶ added in v0.2.4
func (r *Requests) UploadFsToString(targetUrl string, fsObj fs.FS, fileFormName, filePath string) (result string, err error)
UploadFsToString 上传FS系统文件,并将结果转换为字符串返回
func (*Requests) UploadToBytes ¶ added in v0.2.3
UploadToBytes 上传文件并返回响应体字节数组 @param targetUrl 目标地址 @param filePath 上传文件的路径 @return 响应内容,错误对象
type Response ¶ added in v0.2.5
type Response struct { R *http.Response // 响应对象 RawReqDetail string // 请求详情字符串 RawRespDetail string // 响应详情字符串 StatusCode int // 状态码 IsRedirect bool // 是否重定向了 RedirectUrl string // 重定向的的URL地址 StartTime int // 请求开始时间(纳秒) EndTime int // 请求结束时间(纳秒) SpendTime int // 请求消耗时间(纳秒) SpendTimeSeconds int // 请求消耗时间(秒) // contains filtered or unexported fields }
Response 响应对象
func Delete ¶ added in v0.2.5
func Delete(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Delete 发送DELETE请求 @param originUrl 要请求的URL地址 @param args 请求携带的参数
func Patch ¶ added in v0.2.5
func Patch(originUrl string, ignoreParseError bool, args ...interface{}) (resp *Response, err error)
Patch 发送PATCH请求 @param originUrl 要请求的URL地址 @param args 请求携带的参数
func Post ¶ added in v0.2.5
Post 发送POST请求 @param url 要请求的URL路径 @param ignoreParseError 是否忽略解析URL错误 @param args 要携带的参数