Documentation ¶
Index ¶
- Constants
- func DownloadFile(req *Request, path, filename string) error
- func Release(releasers ...Releaser)
- func SetDebugLevel(lvl DebugLevel)
- func SetDefaultClient(client *Client)
- func SetEnvHTTPProxy()
- func SetHTTPProxy(proxy string)
- func SetJsonMarshal(f func(any) ([]byte, error))
- func SetJsonUnmarshal(f func([]byte, any) error)
- func SetOauth1(o *Oauth1)
- func SetSocks5Proxy(proxy string)
- type Body
- type Client
- func (c *Client) AddMiddleware(middlewares ...Middleware)
- func (c *Client) Connect(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Delete(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Do(req *Request, opts ...ReqOption) (*Response, error)
- func (c *Client) DownloadFile(req *Request, path, filename string) error
- func (c *Client) Get(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Head(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Options(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Patch(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Post(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) Put(url string, opts ...ReqOption) (*Response, error)
- func (c *Client) SetDebugLevel(lvl DebugLevel)
- func (c *Client) SetDefaultUserAgent(userAgent string)
- func (c *Client) SetEnvHTTPProxy()
- func (c *Client) SetHTTPProxy(proxy string)
- func (c *Client) SetMaxRedirectsCount(count int)
- func (c *Client) SetOauth1(o *Oauth1)
- func (c *Client) SetRetryIf(retryIf fasthttp.RetryIfFunc)
- func (c *Client) SetSocks5Proxy(proxy string)
- func (c *Client) SetTLSConfig(config *tls.Config)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SkipInsecureVerify(isSkip bool)
- type Cookies
- type Ctx
- type DebugLevel
- type HTTPMethod
- type Headers
- func (h *Headers) Add(key, value string)
- func (h *Headers) AddBytesK(key []byte, value string)
- func (h *Headers) AddBytesKV(key, value []byte)
- func (h *Headers) AddBytesV(key string, value []byte)
- func (h *Headers) AutoRelease(auto bool)
- func (h *Headers) BindRequest(req *Request) error
- func (h *Headers) Del(key string)
- func (h *Headers) DelBytes(key []byte)
- func (h *Headers) Peek(key string) []byte
- func (h *Headers) PeekAll(key string) [][]byte
- func (h *Headers) PeekBytes(key []byte) []byte
- func (h *Headers) Release()
- func (h *Headers) Set(key, value string)
- func (h *Headers) SetBytesK(key []byte, value string)
- func (h *Headers) SetBytesKV(key, value []byte)
- func (h *Headers) SetBytesV(key string, value []byte)
- func (h *Headers) VisitAll(f func(key, value []byte))
- type JsonBody
- type Middleware
- type MultipartForm
- type Oauth1
- type PostForm
- type QueryParams
- type Releaser
- type ReqOption
- type Request
- func (r *Request) AddHeader(k, v string)
- func (r *Request) AddMFField(field, value string) error
- func (r *Request) AddMFFile(fieldName, filePath string) error
- func (r *Request) Copy() *Request
- func (r *Request) Release()
- func (r *Request) SetBasicAuth(username, password string)
- func (r *Request) SetBoundary(boundary string) error
- func (r *Request) SetContentType(contentType string)
- func (r *Request) SetCookie(key, value string)
- func (r *Request) SetCookies(kv ...string)
- func (r *Request) SetHeader(k, v string)
- func (r *Request) SetHeaders(kv ...string)
- func (r *Request) SetHost(host string)
- func (r *Request) SetJSON(v interface{}) error
- func (r *Request) SetMethod(method HTTPMethod)
- func (r *Request) SetPostForm(form *PostForm)
- func (r *Request) SetQueryParams(params *QueryParams)
- func (r *Request) SetQueryString(queryString string)
- func (r *Request) SetReferer(referer string)
- func (r *Request) SetUserAgent(userAgent string)
- func (r *Request) SetXML(v interface{}) error
- type Response
- func Connect(url string, opts ...ReqOption) (*Response, error)
- func Delete(url string, opts ...ReqOption) (*Response, error)
- func Do(req *Request, opts ...ReqOption) (*Response, error)
- func Get(url string, opts ...ReqOption) (*Response, error)
- func Head(url string, opts ...ReqOption) (*Response, error)
- func NewResponse() *Response
- func Options(url string, opts ...ReqOption) (*Response, error)
- func Patch(url string, opts ...ReqOption) (*Response, error)
- func Post(url string, opts ...ReqOption) (*Response, error)
- func Put(url string, opts ...ReqOption) (*Response, error)
- func (r *Response) BodyString() string
- func (r *Response) BuildDom() error
- func (r *Response) Copy() *Response
- func (r *Response) FileName() string
- func (r *Response) Json(v interface{}) error
- func (r *Response) JsonGet(path string) gjson.Result
- func (r *Response) JsonGetMany(path ...string) []gjson.Result
- func (r *Response) JsonGetPartOf(path string, v interface{}) error
- func (r *Response) Release()
- func (r *Response) SaveToFile(path, filename string) error
- type Timeout
Constants ¶
const ( MIMETextXML = "text/xml" MIMETextHTML = "text/html" MIMETextPlain = "text/plain" MIMEApplicationXML = "application/xml" MIMEApplicationJSON = "application/json" MIMEApplicationJavaScript = "application/javascript" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEOctetStream = "application/octet-stream" MIMEMultipartForm = "multipart/form-data" MIMETextXMLCharsetUTF8 = "text/xml; charset=utf-8" MIMETextHTMLCharsetUTF8 = "text/html; charset=utf-8" MIMETextPlainCharsetUTF8 = "text/plain; charset=utf-8" MIMEApplicationXMLCharsetUTF8 = "application/xml; charset=utf-8" MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8" MIMEApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=utf-8" )
const Version = "0.3.2"
Version of fastreq
Variables ¶
This section is empty.
Functions ¶
func DownloadFile ¶ added in v0.2.0
func SetDebugLevel ¶ added in v0.2.2
func SetDebugLevel(lvl DebugLevel)
func SetDefaultClient ¶ added in v0.3.1
func SetDefaultClient(client *Client)
func SetEnvHTTPProxy ¶
func SetEnvHTTPProxy()
func SetHTTPProxy ¶
func SetHTTPProxy(proxy string)
func SetJsonMarshal ¶ added in v0.2.2
SetJsonMarshal can set json marshal function. Default Marshal is github.com/json-iterator/go
func SetJsonUnmarshal ¶ added in v0.2.2
SetJsonUnmarshal can set json unmarshal function. Default Unmarshal is github.com/json-iterator/go
func SetSocks5Proxy ¶
func SetSocks5Proxy(proxy string)
Types ¶
type Body ¶ added in v0.3.0
type Body struct {
// contains filtered or unexported fields
}
func (*Body) AutoRelease ¶ added in v0.3.2
func (*Body) BindRequest ¶ added in v0.3.0
type Client ¶
Client ...
func NewClientFromFastHTTP ¶
NewClientFromFastHTTP ...
func (*Client) AddMiddleware ¶ added in v0.2.1
func (c *Client) AddMiddleware(middlewares ...Middleware)
func (*Client) DownloadFile ¶ added in v0.2.0
func (*Client) SetDebugLevel ¶ added in v0.2.2
func (c *Client) SetDebugLevel(lvl DebugLevel)
func (*Client) SetDefaultUserAgent ¶ added in v0.3.2
func (*Client) SetEnvHTTPProxy ¶
func (c *Client) SetEnvHTTPProxy()
func (*Client) SetHTTPProxy ¶
func (*Client) SetMaxRedirectsCount ¶
func (*Client) SetRetryIf ¶
func (c *Client) SetRetryIf(retryIf fasthttp.RetryIfFunc)
func (*Client) SetSocks5Proxy ¶
func (*Client) SetTLSConfig ¶
func (*Client) SetTimeout ¶
func (*Client) SkipInsecureVerify ¶
type Cookies ¶ added in v0.3.2
type Cookies struct {
// contains filtered or unexported fields
}
func NewCookies ¶ added in v0.3.2
func (*Cookies) AutoRelease ¶ added in v0.3.2
func (*Cookies) BindRequest ¶ added in v0.3.2
type DebugLevel ¶ added in v0.2.2
type DebugLevel int
DebugLevel debug log level
const ( DebugClose DebugLevel = iota // close debug DebugSimple DebugDetail )
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod http request method
const ( GET HTTPMethod = "GET" // RFC 7231, 4.3.1 HEAD HTTPMethod = "HEAD" // RFC 7231, 4.3.2 POST HTTPMethod = "POST" // RFC 7231, 4.3.3 PUT HTTPMethod = "PUT" // RFC 7231, 4.3.4 PATCH HTTPMethod = "PATCH" // RFC 5789 DELETE HTTPMethod = "DELETE" // RFC 7231, 4.3.5 CONNECT HTTPMethod = "CONNECT" // RFC 7231, 4.3.6 OPTIONS HTTPMethod = "OPTIONS" // RFC 7231, 4.3.7 )
type Headers ¶ added in v0.3.2
type Headers struct {
// contains filtered or unexported fields
}
func NewHeaders ¶ added in v0.3.2
func (*Headers) Add ¶ added in v0.3.2
Add adds the given 'key: value' header.
Multiple headers with the same key may be added with this function. Use Set for setting a single header for the given key.
func (*Headers) AddBytesK ¶ added in v0.3.2
AddBytesK adds the given 'key: value' header.
Multiple headers with the same key may be added with this function. Use SetBytesK for setting a single header for the given key.
func (*Headers) AddBytesKV ¶ added in v0.3.2
AddBytesKV adds the given 'key: value' header.
Multiple headers with the same key may be added with this function. Use SetBytesKV for setting a single header for the given key.
the Content-Type, Content-Length, Connection, Cookie, Transfer-Encoding, Host and User-Agent headers can only be set once and will overwrite the previous value.
func (*Headers) AddBytesV ¶ added in v0.3.2
AddBytesV adds the given 'key: value' header.
Multiple headers with the same key may be added with this function. Use SetBytesV for setting a single header for the given key.
func (*Headers) AutoRelease ¶ added in v0.3.2
func (*Headers) BindRequest ¶ added in v0.3.2
func (*Headers) Peek ¶ added in v0.3.2
Peek returns header value for the given key.
The returned value is valid until the request is released, either though ReleaseRequest or your request handler returning. Do not store references to returned value. Make copies instead.
func (*Headers) PeekAll ¶ added in v0.3.2
PeekAll returns all header value for the given key.
The returned value is valid until the request is released, either though ReleaseRequest or your request handler returning. Any future calls to the Peek* will modify the returned value. Do not store references to returned value. Make copies instead.
func (*Headers) PeekBytes ¶ added in v0.3.2
PeekBytes returns header value for the given key.
The returned value is valid until the request is released, either though ReleaseRequest or your request handler returning. Do not store references to returned value. Make copies instead.
func (*Headers) Set ¶ added in v0.3.2
Set sets the given 'key: value' header.
Use Add for setting multiple header values under the same key.
func (*Headers) SetBytesK ¶ added in v0.3.2
SetBytesK sets the given 'key: value' header.
Use AddBytesK for setting multiple header values under the same key.
func (*Headers) SetBytesKV ¶ added in v0.3.2
SetBytesKV sets the given 'key: value' header.
Use AddBytesKV for setting multiple header values under the same key.
func (*Headers) SetBytesV ¶ added in v0.3.2
SetBytesV sets the given 'key: value' header.
Use AddBytesV for setting multiple header values under the same key.
type JsonBody ¶ added in v0.3.0
type JsonBody struct {
// contains filtered or unexported fields
}
func NewJsonBody ¶ added in v0.3.0
func NewJsonBody(b interface{}) *JsonBody
func (*JsonBody) AutoRelease ¶ added in v0.3.2
func (*JsonBody) BindRequest ¶ added in v0.3.0
type Middleware ¶ added in v0.2.0
func MiddlewareOauth1 ¶
func MiddlewareOauth1(o *Oauth1) Middleware
type MultipartForm ¶ added in v0.3.1
type MultipartForm struct { *fasthttp.Args Boundary string // contains filtered or unexported fields }
func NewMultipartForm ¶ added in v0.3.1
func NewMultipartForm(boundary string, kv ...string) *MultipartForm
func (*MultipartForm) AutoRelease ¶ added in v0.3.2
func (mf *MultipartForm) AutoRelease(auto bool)
func (*MultipartForm) BindRequest ¶ added in v0.3.1
func (mf *MultipartForm) BindRequest(req *Request) error
func (*MultipartForm) Release ¶ added in v0.3.1
func (mf *MultipartForm) Release()
type Oauth1 ¶
type PostForm ¶ added in v0.3.0
func NewPostForm ¶ added in v0.3.0
func (*PostForm) AutoRelease ¶ added in v0.3.2
func (*PostForm) BindRequest ¶ added in v0.3.0
type QueryParams ¶ added in v0.3.0
func NewQueryParams ¶ added in v0.3.0
func NewQueryParams(kv ...string) *QueryParams
func (*QueryParams) AutoRelease ¶ added in v0.3.2
func (q *QueryParams) AutoRelease(auto bool)
func (*QueryParams) BindRequest ¶ added in v0.3.0
func (q *QueryParams) BindRequest(req *Request) error
func (*QueryParams) Release ¶ added in v0.3.0
func (q *QueryParams) Release()
type Request ¶
Request ...
func NewRequest ¶
func NewRequest(method HTTPMethod, url string) *Request
func NewRequestFromFastHTTP ¶
func (*Request) AddMFField ¶ added in v0.3.1
func (*Request) SetBasicAuth ¶
func (*Request) SetBoundary ¶ added in v0.3.1
func (*Request) SetContentType ¶
func (*Request) SetCookies ¶
func (*Request) SetHeaders ¶
func (*Request) SetMethod ¶
func (r *Request) SetMethod(method HTTPMethod)
func (*Request) SetPostForm ¶ added in v0.3.1
func (*Request) SetQueryParams ¶ added in v0.2.0
func (r *Request) SetQueryParams(params *QueryParams)
func (*Request) SetQueryString ¶
func (*Request) SetReferer ¶
func (*Request) SetUserAgent ¶
type Response ¶
Response ...
func NewResponse ¶
func NewResponse() *Response
func (*Response) BodyString ¶
func (*Response) JsonGetPartOf ¶ added in v0.2.2
func (*Response) SaveToFile ¶ added in v0.2.0
type Timeout ¶ added in v0.3.0
type Timeout struct {
// contains filtered or unexported fields
}