Documentation
¶
Index ¶
- Constants
- Variables
- type Auth
- type BasicAuth
- type Body
- func (c *Body) GetBytes() []byte
- func (c *Body) GetRaw() io.Reader
- func (c *Body) GetStrings() string
- func (c *Body) GetWithJson() (interface{}, error)
- func (c *Body) GetWithJsonStruct(target interface{}) error
- func (c *Body) Path(path string) *Body
- func (c *Body) SaveFile() *Body
- func (c *Body) Set(body io.Reader) *HTTPClient
- func (c *Body) SetByte(body []byte) *HTTPClient
- func (c *Body) SetJson(data interface{}) *HTTPClient
- func (c *Body) SetString(body string) *HTTPClient
- func (c *Body) ToFile(fileName string)
- type ContentType
- type Cookie
- func (c *Cookie) Get() []*http.Cookie
- func (c *Cookie) Load() *Cookie
- func (c *Cookie) Path(path string) *Cookie
- func (c *Cookie) Save() *Cookie
- func (c *Cookie) SetCookieJar(jar *cookiejar.Jar) *HTTPClient
- func (c *Cookie) SetCookies(cookies []*http.Cookie) *HTTPClient
- func (c *Cookie) SetString(cookie string) *HTTPClient
- type FormData
- func (c *FormData) AddField(key, value string) *FormData
- func (c *FormData) AddFile(key, path string) *FormData
- func (c *FormData) Push() *HTTPClient
- func (c *FormData) SetFieldEncode(key, value string) *FormData
- func (c *FormData) SetFields(fields *map[string]string) *HTTPClient
- func (c *FormData) WithMultipart() *FormData
- type HTTPClient
- func (c *HTTPClient) Auth() *Auth
- func (c *HTTPClient) Body() *Body
- func (c *HTTPClient) Close() []error
- func (c *HTTPClient) ContentType() *ContentType
- func (c *HTTPClient) Cookie() *Cookie
- func (c *HTTPClient) Delete(u string) *HTTPClient
- func (c *HTTPClient) Do() *HTTPClient
- func (c *HTTPClient) DoWithContext(ctx context.Context) *HTTPClient
- func (c *HTTPClient) FormData() *FormData
- func (c *HTTPClient) Get(u string) *HTTPClient
- func (c *HTTPClient) GetCurrentUrl() *url.URL
- func (c *HTTPClient) GetErrors() []error
- func (c *HTTPClient) GetResponse() (*http.Response, []error)
- func (c *HTTPClient) Head(u string) *HTTPClient
- func (c *HTTPClient) Header() *Header
- func (c *HTTPClient) MaxRedirect(maxRedirect int) *HTTPClient
- func (c *HTTPClient) Patch(u string) *HTTPClient
- func (c *HTTPClient) Post(u string) *HTTPClient
- func (c *HTTPClient) Proxy() *Proxy
- func (c *HTTPClient) Put(u string) *HTTPClient
- func (c *HTTPClient) Request()
- func (c *HTTPClient) ResetClient() *HTTPClient
- func (c *HTTPClient) RetryIf(statusCodes ...int) *HTTPClient
- func (c *HTTPClient) RetryMax(maxRetries int) *HTTPClient
- func (c *HTTPClient) SetMethod(method string) *HTTPClient
- func (c *HTTPClient) SetRequest(req *http.Request) *HTTPClient
- func (c *HTTPClient) SetTLSConfig(config *tls.Config) *HTTPClient
- func (c *HTTPClient) SetTimeout(timeout time.Duration) *HTTPClient
- func (c *HTTPClient) SetTimeoutSecons(second time.Duration) *HTTPClient
- func (c *HTTPClient) SetURL(u string) *HTTPClient
- func (c *HTTPClient) SetUserAgent(agent string) *HTTPClient
- func (c *HTTPClient) Status() *Status
- type Header
- type Proxy
- type Request
- type SerializableCookies
- type Status
Constants ¶
const ( MethodGet = "GET" MethodHead = "HEAD" MethodPost = "POST" MethodPut = "PUT" MethodPatch = "PATCH" // RFC 5789 MethodDelete = "DELETE" MethodConnect = "CONNECT" MethodOptions = "OPTIONS" MethodTrace = "TRACE" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
Client *HTTPClient
}
func (*Auth) SetBasic ¶
func (c *Auth) SetBasic(user, pass string) *HTTPClient
Sets basic auth in request
func (*Auth) SetBearer ¶
func (c *Auth) SetBearer(token string) *HTTPClient
Sets bearer token in header request
func (*Auth) SetToken ¶
func (c *Auth) SetToken(token string) *HTTPClient
Sets custom auth token in header request
type Body ¶
type Body struct {
Client *HTTPClient
// contains filtered or unexported fields
}
func (*Body) GetStrings ¶
Gets response body and return as string
func (*Body) GetWithJson ¶
Gets response body and return as interface map array
func (*Body) GetWithJsonStruct ¶
Gets response body and make to struct
func (*Body) Set ¶
func (c *Body) Set(body io.Reader) *HTTPClient
Sets the request body with io.Reader
func (*Body) SetByte ¶
func (c *Body) SetByte(body []byte) *HTTPClient
Sets the request body with bytes
func (*Body) SetJson ¶
func (c *Body) SetJson(data interface{}) *HTTPClient
Sets the request body with json
func (*Body) SetString ¶
func (c *Body) SetString(body string) *HTTPClient
Sets the request body with only string
type ContentType ¶
type ContentType struct {
Client *HTTPClient
}
func (*ContentType) Get ¶
func (c *ContentType) Get() string
Gets content type fron response headers and return as string
func (*ContentType) Set ¶
func (c *ContentType) Set(value string) *HTTPClient
Sets content type in request header
func (*ContentType) SetFormUrlencoded ¶
func (c *ContentType) SetFormUrlencoded() *HTTPClient
Sets content type in request header
func (*ContentType) SetMultipartFormData ¶
func (c *ContentType) SetMultipartFormData() *HTTPClient
Sets content type in request header
type Cookie ¶
type Cookie struct {
Client *HTTPClient
// contains filtered or unexported fields
}
func (*Cookie) Save ¶
Save cookies to file for next requests by default saves to the cookies/domainname directory
func (*Cookie) SetCookieJar ¶
func (c *Cookie) SetCookieJar(jar *cookiejar.Jar) *HTTPClient
func (*Cookie) SetCookies ¶
func (c *Cookie) SetCookies(cookies []*http.Cookie) *HTTPClient
Sets cookies as *http.Cookie
func (*Cookie) SetString ¶
func (c *Cookie) SetString(cookie string) *HTTPClient
Sets cookies as string ex: name=xxxx; count=x
type FormData ¶
type FormData struct {
Client *HTTPClient
// contains filtered or unexported fields
}
func (*FormData) SetFieldEncode ¶
type HTTPClient ¶
type HTTPClient struct {
Timeout time.Duration
BodyBytes []byte
// contains filtered or unexported fields
}
func New ¶
func New() *HTTPClient
func (*HTTPClient) Close ¶
func (c *HTTPClient) Close() []error
func (*HTTPClient) ContentType ¶
func (c *HTTPClient) ContentType() *ContentType
func (*HTTPClient) Cookie ¶
func (c *HTTPClient) Cookie() *Cookie
This method init client with cookie
func (*HTTPClient) Delete ¶
func (c *HTTPClient) Delete(u string) *HTTPClient
func (*HTTPClient) DoWithContext ¶
func (c *HTTPClient) DoWithContext(ctx context.Context) *HTTPClient
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(u string) *HTTPClient
func (*HTTPClient) GetCurrentUrl ¶
func (c *HTTPClient) GetCurrentUrl() *url.URL
func (*HTTPClient) GetErrors ¶
func (c *HTTPClient) GetErrors() []error
func (*HTTPClient) GetResponse ¶
func (c *HTTPClient) GetResponse() (*http.Response, []error)
func (*HTTPClient) Head ¶
func (c *HTTPClient) Head(u string) *HTTPClient
func (*HTTPClient) MaxRedirect ¶
func (c *HTTPClient) MaxRedirect(maxRedirect int) *HTTPClient
Set max redirect count 0 = disable redirects
func (*HTTPClient) Patch ¶
func (c *HTTPClient) Patch(u string) *HTTPClient
func (*HTTPClient) Post ¶
func (c *HTTPClient) Post(u string) *HTTPClient
func (*HTTPClient) Proxy ¶
func (c *HTTPClient) Proxy() *Proxy
func (*HTTPClient) Put ¶
func (c *HTTPClient) Put(u string) *HTTPClient
func (*HTTPClient) Request ¶
func (c *HTTPClient) Request()
func (*HTTPClient) ResetClient ¶
func (c *HTTPClient) ResetClient() *HTTPClient
func (*HTTPClient) RetryIf ¶
func (c *HTTPClient) RetryIf(statusCodes ...int) *HTTPClient
Sets the conditions for retrying a http request
func (*HTTPClient) RetryMax ¶
func (c *HTTPClient) RetryMax(maxRetries int) *HTTPClient
Sets the counts for retrying a http request
func (*HTTPClient) SetMethod ¶
func (c *HTTPClient) SetMethod(method string) *HTTPClient
func (*HTTPClient) SetRequest ¶
func (c *HTTPClient) SetRequest(req *http.Request) *HTTPClient
func (*HTTPClient) SetTLSConfig ¶
func (c *HTTPClient) SetTLSConfig(config *tls.Config) *HTTPClient
func (*HTTPClient) SetTimeout ¶
func (c *HTTPClient) SetTimeout(timeout time.Duration) *HTTPClient
func (*HTTPClient) SetTimeoutSecons ¶
func (c *HTTPClient) SetTimeoutSecons(second time.Duration) *HTTPClient
func (*HTTPClient) SetURL ¶
func (c *HTTPClient) SetURL(u string) *HTTPClient
func (*HTTPClient) SetUserAgent ¶
func (c *HTTPClient) SetUserAgent(agent string) *HTTPClient
type Header ¶
type Header struct {
Client *HTTPClient
}
func (*Header) Add ¶
func (c *Header) Add(header *map[string]string) *HTTPClient
Sets headers from string map object
func (*Header) GetWithStringMap ¶
Gets header and convert in string map
type Proxy ¶
type Proxy struct {
Client *HTTPClient
}
func (*Proxy) SetProxy ¶
func (c *Proxy) SetProxy(uri string) *HTTPClient