Documentation ¶
Index ¶
- Constants
- func IsJSONType(ct string) bool
- func IsXMLType(ct string) bool
- type Client
- type GetContentFunc
- type Request
- func (r *Request) Do(ctx context.Context) (resp *Response, err error)
- func (r *Request) Request(method, rowUrl string) *Request
- func (r *Request) SetBody(body interface{}) *Request
- func (r *Request) SetBodyBytes(body []byte) *Request
- func (r *Request) SetBodyJsonBytes(body []byte) *Request
- func (r *Request) SetBodyString(body string) *Request
- func (r *Request) SetContentType(contentType string) *Request
- func (r *Request) SetFormData(data map[string]string) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetHeaders(headers map[string]string) *Request
- func (r *Request) SetMethod(method string) *Request
- func (r *Request) SetQuery(queries map[string]string) *Request
- func (r *Request) SetRowUrl(rowUrl string) *Request
- type RequestMiddleware
- type Response
- type ResponseMiddleware
- type RetryHookFunc
- type RoundTripper
Constants ¶
View Source
const ( DefaultUserAgent = "req/v3 (https://github.com/imroc/req)" UserAgent = "User-Agent" Location = "Location" ContentType = "Content-Type" PlainTextContentType = "text/plain; charset=utf-8" JsonContentType = "application/json; charset=utf-8" XmlContentType = "text/xml; charset=utf-8" FormContentType = "application/x-www-form-urlencoded" WwwAuthenticate = "WWW-Authenticate" Authorization = "Authorization" HeaderOderKey = "__header_order__" PseudoHeaderOderKey = "__pseudo_header_order__" )
Variables ¶
This section is empty.
Functions ¶
func IsJSONType ¶
IsJSONType method is to check JSON content type or not
Types ¶
type GetContentFunc ¶
type GetContentFunc func() (io.ReadCloser, error)
type Request ¶
type Request struct { Headers http.Header // 请求头 RawRequest *http.Request // 请求对象 RowUrl string // 请求地址 URL *url.URL // 请求地址结构体 Method string // 请求方式 Body []byte // 请求请求主体 GetBody GetContentFunc // 获取请求主体方法 Cookies []*http.Cookie // cookie Timeout time.Duration // 超时时间 Queries map[string]string // contains filtered or unexported fields }
func (*Request) SetBodyBytes ¶
func (*Request) SetBodyJsonBytes ¶
func (*Request) SetBodyString ¶
func (*Request) SetContentType ¶
type RequestMiddleware ¶
RequestMiddleware type is for request middleware, called before a request is sent
type ResponseMiddleware ¶
ResponseMiddleware type is for response middleware, called after a response has been received
type RetryHookFunc ¶
Click to show internal directories.
Click to hide internal directories.