Documentation ¶
Index ¶
- Constants
- Variables
- func EscapePath(path string) string
- func IsInvalidStatusCode(err error, statusCode int) bool
- type Encoding
- type ErrorHandlerFunc
- type HTTPClient
- func (c *HTTPClient) Request(req *RequestData) (response *http.Response, err error)
- func (c *HTTPClient) SetErrorHandler(handler ErrorHandlerFunc)
- func (c *HTTPClient) SetPostHook(onStatus int, hook PostHookFunc)
- func (c *HTTPClient) SetRateLimit(limit int, timeout time.Duration)
- func (c *HTTPClient) UseInvalidStatusErrorPtr()
- type InvalidStatusError
- type PostHookFunc
- type RequestData
- func (r *RequestData) CanCopy() bool
- func (r *RequestData) Copy() (ok bool, nr *RequestData)
- func (req *RequestData) UploadFile(fieldName string, fileName string, reader io.Reader) (err error)
- func (req *RequestData) UploadFileExtra(fieldName string, fileName string, reader io.Reader, extra map[string]string) (err error)
Constants ¶
View Source
const ( EncodingJSON = "JSON" EncodingXML = "XML" EncodingForm = "Form" )
Variables ¶
View Source
var DefaultClient = New()
View Source
var HttpClient = &http.Client{ Transport: HttpTransport, }
View Source
var HttpTransport = &http.Transport{ DisableCompression: true, Proxy: http.ProxyFromEnvironment, }
View Source
var InsecureHttpClient = &http.Client{ Transport: InsecureHttpTransport, }
View Source
var InsecureHttpTransport = &http.Transport{ TLSClientConfig: InsecureTlsConfig, DisableCompression: true, Proxy: http.ProxyFromEnvironment, }
View Source
var InsecureTlsConfig = &tls.Config{ InsecureSkipVerify: true, }
View Source
var RateLimitTimeoutError = errors.New("HTTPClient rate limit timeout")
View Source
var XmlHeaderBytes []byte = []byte(xml.Header)
Functions ¶
func EscapePath ¶
func IsInvalidStatusCode ¶
Types ¶
type HTTPClient ¶
type HTTPClient struct { BaseURL *url.URL Headers http.Header Client *http.Client PostHooks map[int]PostHookFunc // contains filtered or unexported fields }
func Insecure ¶
func Insecure() (httpClient *HTTPClient)
func New ¶
func New() (httpClient *HTTPClient)
func (*HTTPClient) Request ¶
func (c *HTTPClient) Request(req *RequestData) (response *http.Response, err error)
func (*HTTPClient) SetErrorHandler ¶
func (c *HTTPClient) SetErrorHandler(handler ErrorHandlerFunc)
func (*HTTPClient) SetPostHook ¶
func (c *HTTPClient) SetPostHook(onStatus int, hook PostHookFunc)
func (*HTTPClient) SetRateLimit ¶
func (c *HTTPClient) SetRateLimit(limit int, timeout time.Duration)
func (*HTTPClient) UseInvalidStatusErrorPtr ¶
func (c *HTTPClient) UseInvalidStatusErrorPtr()
type InvalidStatusError ¶
func IsInvalidStatusError ¶
func IsInvalidStatusError(err error) (invalidStatusError *InvalidStatusError, ok bool)
func (InvalidStatusError) Error ¶
func (e InvalidStatusError) Error() string
type RequestData ¶
type RequestData struct { Context context.Context Method string Path string Params url.Values FullURL string // client.BaseURL + Path or FullURL Headers http.Header ReqReader io.Reader ReqEncoding Encoding ReqValue interface{} ReqContentLength int64 ExpectedStatus []int IgnoreRedirects bool RespEncoding Encoding RespValue interface{} RespConsume bool }
func (*RequestData) CanCopy ¶
func (r *RequestData) CanCopy() bool
func (*RequestData) Copy ¶
func (r *RequestData) Copy() (ok bool, nr *RequestData)
func (*RequestData) UploadFile ¶
func (*RequestData) UploadFileExtra ¶
Click to show internal directories.
Click to hide internal directories.