Documentation ¶
Index ¶
- Constants
- Variables
- type Request
- func BaseURL(url string) Request
- func Cookie(c *http.Cookie) Request
- func Header(key, val string) Request
- func New() Request
- func Proxy(url string) Request
- func Query(query interface{}) Request
- func Timeout(timeout time.Duration) Request
- func Type(name string) Request
- func UseRequest(mdl requestMiddlewareHandler) Request
- func UseResponse(mdl responseMidlewareHandler) Request
- func UserAgent(name string) Request
- func (r Request) BaseURL(url string) Request
- func (r Request) Clone() Request
- func (r Request) Cookie(c *http.Cookie) Request
- func (r Request) Del(url string, body ...interface{}) (*Response, error)
- func (r Request) Do(method, url string, args ...interface{}) (*Response, error)
- func (r Request) Get(url string, args ...interface{}) (*Response, error)
- func (r Request) Head(url string, args ...interface{}) (*Response, error)
- func (r Request) Header(key, val string) Request
- func (r Request) Options(url string, args ...interface{}) (*Response, error)
- func (r Request) Patch(url string, body ...interface{}) (*Response, error)
- func (r Request) Post(url string, body ...interface{}) (*Response, error)
- func (r Request) PostFile(url string, file interface{}, body interface{}) (*Response, error)
- func (r Request) Proxy(url string) Request
- func (r Request) Put(url string, body ...interface{}) (*Response, error)
- func (r Request) PutFile(url string, file interface{}, body interface{}) (*Response, error)
- func (r Request) Query(query interface{}) Request
- func (r Request) Timeout(timeout time.Duration) Request
- func (r Request) Type(name string) Request
- func (r Request) UseRequest(mdl requestMiddlewareHandler) Request
- func (r Request) UseResponse(mdl responseMidlewareHandler) Request
- func (r Request) UserAgent(name string) Request
- type Response
- func Del(url string, body interface{}) (*Response, error)
- func Get(url string, query interface{}) (*Response, error)
- func Head(url string, query interface{}) (*Response, error)
- func NewResponse() *Response
- func Options(url string, query interface{}) (*Response, error)
- func Patch(url string, body interface{}) (*Response, error)
- func Post(url string, body interface{}) (*Response, error)
- func PostFile(url string, file interface{}, body interface{}) (*Response, error)
- func Put(url string, body interface{}) (*Response, error)
- func PutFile(url string, file interface{}, body interface{}) (*Response, error)
- type ResponseError
- type SuperAgent
- func (s *SuperAgent) Proxy(proxyUrl string) *SuperAgent
- func (s *SuperAgent) Query(content interface{}) *SuperAgent
- func (s *SuperAgent) Send(content interface{}) *SuperAgent
- func (s *SuperAgent) SendMap(content interface{}) *SuperAgent
- func (s *SuperAgent) SendSlice(content []interface{}) *SuperAgent
- func (s *SuperAgent) SendString(content string) *SuperAgent
- func (s *SuperAgent) SendStruct(content interface{}) *SuperAgent
- func (s *SuperAgent) Timeout(timeout time.Duration) *SuperAgent
- func (s *SuperAgent) Type(typeStr string) *SuperAgent
Constants ¶
View Source
const ( TypeJSON = "json" TypeXML = "xml" TypeUrlencoded = "urlencoded" TypeForm = "form" TypeFormData = "form-data" TypeHTML = "html" TypeText = "text" TypeMultipart = "multipart" )
Variables ¶
View Source
var Types = map[string]string{ TypeJSON: "application/json", TypeXML: "application/xml", TypeForm: "application/x-www-form-urlencoded", TypeFormData: "application/x-www-form-urlencoded", TypeUrlencoded: "application/x-www-form-urlencoded", TypeHTML: "text/html", TypeText: "text/plain", TypeMultipart: "multipart/form-data", }
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct { SuperAgent *SuperAgent // contains filtered or unexported fields }
Request 请求结构
func (Request) PostFile ¶
PostFile 发起 post 请求上传文件,将使用表单提交,file 是文件地址或者文件流, body 是请求带的参数,可使用json字符串或者结构体
func (Request) PutFile ¶
PutFile 发起 put 请求上传文件,将使用表单提交,file 是文件地址或者文件流, body 是请求带的参数,可使用json字符串或者结构体
func (Request) UseRequest ¶
UseRequest 增加请求中间件
func (Request) UseResponse ¶
UseResponse 增加响应中间件
type Response ¶
type Response struct { Request *Request Raw *http.Response Body []byte Errs ResponseError }
Response 回应对象
type SuperAgent ¶ added in v1.0.13
type SuperAgent struct { Url string Method string Header http.Header TargetType string ForceType string Data map[string]interface{} SliceData []interface{} FormData url.Values QueryData url.Values //FileData []File BounceToRawString bool RawString string Client *http.Client Transport *http.Transport Cookies []*http.Cookie Errors []error BasicAuth struct{ Username, Password string } Debug bool CurlCommand bool //logger Logger //Retryable superAgentRetryable DoNotClearSuperAgent bool // contains filtered or unexported fields }
func (*SuperAgent) Proxy ¶ added in v1.0.13
func (s *SuperAgent) Proxy(proxyUrl string) *SuperAgent
func (*SuperAgent) Query ¶ added in v1.0.13
func (s *SuperAgent) Query(content interface{}) *SuperAgent
func (*SuperAgent) Send ¶ added in v1.0.13
func (s *SuperAgent) Send(content interface{}) *SuperAgent
func (*SuperAgent) SendMap ¶ added in v1.0.13
func (s *SuperAgent) SendMap(content interface{}) *SuperAgent
func (*SuperAgent) SendSlice ¶ added in v1.0.13
func (s *SuperAgent) SendSlice(content []interface{}) *SuperAgent
func (*SuperAgent) SendString ¶ added in v1.0.13
func (s *SuperAgent) SendString(content string) *SuperAgent
func (*SuperAgent) SendStruct ¶ added in v1.0.13
func (s *SuperAgent) SendStruct(content interface{}) *SuperAgent
func (*SuperAgent) Timeout ¶ added in v1.0.13
func (s *SuperAgent) Timeout(timeout time.Duration) *SuperAgent
func (*SuperAgent) Type ¶ added in v1.0.13
func (s *SuperAgent) Type(typeStr string) *SuperAgent
Click to show internal directories.
Click to hide internal directories.