Versions in this module Expand all Collapse all v0 v0.0.2 May 23, 2021 v0.0.1 May 23, 2021 Changes in this version + const MethodDelete + const MethodGet + const MethodHead + const MethodOptions + const MethodPatch + const MethodPost + const MethodPut + func Backoff(operation func() (*Response, error), options ...Option) error + func DetectContentType(body interface{}) string + func IsJSONType(ct string) bool + func IsStringEmpty(str string) bool + func IsXMLType(ct string) bool + func Unmarshalc(c *HttpClient, ct string, b []byte, d interface{}) (err error) + type ErrorHook func(*Request, error) + type File struct + Name string + ParamName string + func (f *File) String() string + type HttpClient struct + AllowGetMethodPayload bool + AuthScheme string + BaseUrl string + Cookies []*http.Cookie + Debug bool + DisableWarn bool + Error reflect.Type + FormData url.Values + Header http.Header + HeaderAuthorizationKey string + Marshaller marshallers.Marshaller + QueryParam url.Values + RetryAfter RetryAfterFunc + RetryConditions []RetryConditionFunc + RetryCount int + RetryHooks []OnRetryFunc + RetryMaxWaitTime time.Duration + RetryWaitTime time.Duration + Token string + UserInfo *User + func New() *HttpClient + func NewWithClient(hc *http.Client) *HttpClient + func NewWithLocalAddr(localAddr net.Addr) *HttpClient + func (c *HttpClient) AddRetryAfterErrorCondition() *HttpClient + func (c *HttpClient) AddRetryCondition(condition RetryConditionFunc) *HttpClient + func (c *HttpClient) AddRetryHook(hook OnRetryFunc) *HttpClient + func (c *HttpClient) DisableTrace() *HttpClient + func (c *HttpClient) EnableTrace() *HttpClient + func (c *HttpClient) GetClient() *http.Client + func (c *HttpClient) IsProxySet() bool + func (c *HttpClient) NewRequest() *Request + func (c *HttpClient) OnAfterResponse(m ResponseMiddleware) *HttpClient + func (c *HttpClient) OnBeforeRequest(m RequestMiddleware) *HttpClient + func (c *HttpClient) OnError(h ErrorHook) *HttpClient + func (c *HttpClient) OnRequestLog(rl RequestLogCallback) *HttpClient + func (c *HttpClient) OnResponseLog(rl ResponseLogCallback) *HttpClient + func (c *HttpClient) RemoveProxy() *HttpClient + func (c *HttpClient) UseAllowGetMethodPayload(a bool) *HttpClient + func (c *HttpClient) UseAuthenticationSchema(scheme string) *HttpClient + func (c *HttpClient) UseAuthenticationToken(token string) *HttpClient + func (c *HttpClient) UseBaseUrl(url string) *HttpClient + func (c *HttpClient) UseBasicAuthentication(username, password string) *HttpClient + func (c *HttpClient) UseCertificates(certs ...tls.Certificate) *HttpClient + func (c *HttpClient) UseCloseConnection(close bool) *HttpClient + func (c *HttpClient) UseContentLength(l bool) *HttpClient + func (c *HttpClient) UseCookie(hc *http.Cookie) *HttpClient + func (c *HttpClient) UseCookieJar(jar http.CookieJar) *HttpClient + func (c *HttpClient) UseCookies(cs []*http.Cookie) *HttpClient + func (c *HttpClient) UseDebug(d bool) *HttpClient + func (c *HttpClient) UseDebugBodyLimit(sl int64) *HttpClient + func (c *HttpClient) UseDisableWarnings(d bool) *HttpClient + func (c *HttpClient) UseDoNotParseResponse(parse bool) *HttpClient + func (c *HttpClient) UseError(err interface{}) *HttpClient + func (c *HttpClient) UseFormData(data map[string]string) *HttpClient + func (c *HttpClient) UseHeader(header, value string) *HttpClient + func (c *HttpClient) UseHeaderVerbatim(header, value string) *HttpClient + func (c *HttpClient) UseHeaders(headers map[string]string) *HttpClient + func (c *HttpClient) UseJSONEscapeHTML(b bool) *HttpClient + func (c *HttpClient) UseLogger(l logger.Logger) *HttpClient + func (c *HttpClient) UseOutputDirectory(dirPath string) *HttpClient + func (c *HttpClient) UsePathParam(param, value string) *HttpClient + func (c *HttpClient) UsePathParams(params map[string]string) *HttpClient + func (c *HttpClient) UsePreRequestHook(h PreRequestHook) *HttpClient + func (c *HttpClient) UseProxy(proxyURL string) *HttpClient + func (c *HttpClient) UseQueryParam(param, value string) *HttpClient + func (c *HttpClient) UseQueryParams(params map[string]string) *HttpClient + func (c *HttpClient) UseRedirectPolicy(policies ...interface{}) *HttpClient + func (c *HttpClient) UseRetryAfter(callback RetryAfterFunc) *HttpClient + func (c *HttpClient) UseRetryCount(count int) *HttpClient + func (c *HttpClient) UseRetryMaxWaitTime(maxWaitTime time.Duration) *HttpClient + func (c *HttpClient) UseRetryWaitTime(waitTime time.Duration) *HttpClient + func (c *HttpClient) UseRootCertificate(pemFilePath string) *HttpClient + func (c *HttpClient) UseRootCertificateFromString(pemContent string) *HttpClient + func (c *HttpClient) UseSchema(scheme string) *HttpClient + func (c *HttpClient) UseTLSClientConfiguration(config *tls.Config) *HttpClient + func (c *HttpClient) UseTimeout(timeout time.Duration) *HttpClient + func (c *HttpClient) UseTransport(transport http.RoundTripper) *HttpClient + type MultipartField struct + ContentType string + FileName string + Param string + type OnRetryFunc func(*Response, error) + type Option func(*Options) + func MaxWaitTime(value time.Duration) Option + func Retries(value int) Option + func RetryConditions(conditions []RetryConditionFunc) Option + func RetryHooks(hooks []OnRetryFunc) Option + func WaitTime(value time.Duration) Option + type Options struct + type PreRequestHook func(*HttpClient, *http.Request) error + type RedirectPolicy interface + Apply func(req *http.Request, via []*http.Request) error + func DomainCheckRedirectPolicy(hostnames ...string) RedirectPolicy + func FlexibleRedirectPolicy(noOfRedirect int) RedirectPolicy + func NoRedirectPolicy() RedirectPolicy + type RedirectPolicyFunc func(*http.Request, []*http.Request) error + func (f RedirectPolicyFunc) Apply(req *http.Request, via []*http.Request) error + type Request struct + Attempt int + AuthScheme string + Body interface{} + Cookies []*http.Cookie + Error interface{} + FormData url.Values + Header http.Header + Method string + QueryParam url.Values + RawRequest *http.Request + Result interface{} + SRV *SRVRecord + Time time.Time + Token string + URL string + UserInfo *User + func (r *Request) Context() context.Context + func (r *Request) Delete(url string) (*Response, error) + func (r *Request) EnableTrace() *Request + func (r *Request) Execute(method, url string) (*Response, error) + func (r *Request) ExpectContentType(contentType string) *Request + func (r *Request) ForceContentType(contentType string) *Request + func (r *Request) Get(url string) (*Response, error) + func (r *Request) Head(url string) (*Response, error) + func (r *Request) Options(url string) (*Response, error) + func (r *Request) Patch(url string) (*Response, error) + func (r *Request) Post(url string) (*Response, error) + func (r *Request) Put(url string) (*Response, error) + func (r *Request) Send() (*Response, error) + func (r *Request) TraceInfo() TraceInfo + func (r *Request) UseAuthenticationSchema(scheme string) *Request + func (r *Request) UseAuthenticationToken(token string) *Request + func (r *Request) UseBasicAuthentication(username, password string) *Request + func (r *Request) UseBody(body interface{}) *Request + func (r *Request) UseContentLength(l bool) *Request + func (r *Request) UseContext(ctx context.Context) *Request + func (r *Request) UseCookie(hc *http.Cookie) *Request + func (r *Request) UseCookies(rs []*http.Cookie) *Request + func (r *Request) UseDoNotParseResponse(parse bool) *Request + func (r *Request) UseError(err interface{}) *Request + func (r *Request) UseFile(param, filePath string) *Request + func (r *Request) UseFileReader(param, fileName string, reader io.Reader) *Request + func (r *Request) UseFiles(files map[string]string) *Request + func (r *Request) UseFormData(data map[string]string) *Request + func (r *Request) UseFormDataFromValues(data url.Values) *Request + func (r *Request) UseHeader(header, value string) *Request + func (r *Request) UseHeaderVerbatim(header, value string) *Request + func (r *Request) UseHeaders(headers map[string]string) *Request + func (r *Request) UseJSONEscapeHTML(b bool) *Request + func (r *Request) UseMultipartField(param, fileName, contentType string, reader io.Reader) *Request + func (r *Request) UseMultipartFields(fields ...*MultipartField) *Request + func (r *Request) UseMultipartFormData(data map[string]string) *Request + func (r *Request) UseOutputFile(file string) *Request + func (r *Request) UsePathParam(param, value string) *Request + func (r *Request) UsePathParams(params map[string]string) *Request + func (r *Request) UseQueryParam(param, value string) *Request + func (r *Request) UseQueryParams(params map[string]string) *Request + func (r *Request) UseQueryParamsFromValues(params url.Values) *Request + func (r *Request) UseQueryString(query string) *Request + func (r *Request) UseResponse(res interface{}) *Request + func (r *Request) UseSRV(srv *SRVRecord) *Request + type RequestLog struct + Body string + Header http.Header + type RequestLogCallback func(*RequestLog) error + type RequestMiddleware func(*HttpClient, *Request) error + type Response struct + RawResponse *http.Response + Request *Request + func (r *Response) CalculateDuration() time.Duration + func (r *Response) ExtractBody() []byte + func (r *Response) ExtractBodyAsString() string + func (r *Response) ExtractCookies() []*http.Cookie + func (r *Response) ExtractError() interface{} + func (r *Response) ExtractHeader() http.Header + func (r *Response) ExtractProto() string + func (r *Response) ExtractRawBody() io.ReadCloser + func (r *Response) ExtractResult() interface{} + func (r *Response) ExtractStatus() string + func (r *Response) ExtractStatusCode() int + func (r *Response) IsError() bool + func (r *Response) IsSuccess() bool + func (r *Response) ReceivedAt() time.Time + func (r *Response) Size() int64 + type ResponseError struct + Err error + Response *Response + func (e *ResponseError) Error() string + func (e *ResponseError) Unwrap() error + type ResponseLog struct + Body string + Header http.Header + type ResponseLogCallback func(*ResponseLog) error + type ResponseMiddleware func(*HttpClient, *Response) error + type RetryAfterFunc func(*HttpClient, *Response) (time.Duration, error) + type RetryConditionFunc func(*Response, error) bool + type SRVRecord struct + Domain string + Service string + type TraceInfo struct + ConnIdleTime time.Duration + ConnTime time.Duration + DNSLookup time.Duration + IsConnReused bool + IsConnWasIdle bool + RemoteAddr net.Addr + RequestAttempt int + ResponseTime time.Duration + ServerTime time.Duration + TCPConnTime time.Duration + TLSHandshake time.Duration + TotalTime time.Duration + type User struct + Password string + Username string