Versions in this module Expand all Collapse all v0 v0.0.1 Jun 6, 2021 Changes in this version + const MethodDelete + const MethodGet + const MethodHead + const MethodOptions + const MethodPatch + const MethodPost + const MethodPut + func Backoff(operation func() (*HttpResponse, 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(*HttpRequest, 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 interfaces.Marshaller + QueryParam url.Values + RetryAfter RetryAfterFunc + RetryConditions []RetryConditionFunc + RetryCount int + RetryHooks []OnRetryFunc + RetryMaxWaitTime time.Duration + RetryWaitTime time.Duration + Token string + UserInfo *User + func New(logger logging.Logger, marshaller interfaces.Marshaller) (*HttpClient, error) + func NewWithClient(logger logging.Logger, marshaller interfaces.Marshaller, hc *http.Client) (*HttpClient, error) + func NewWithLocalAddr(logger logging.Logger, marshaller interfaces.Marshaller, localAddr net.Addr) (*HttpClient, error) + 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() *HttpRequest + 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 logging.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 HttpRedirectionPolicy interface + Apply func(req *http.Request, via []*http.Request) error + func DomainCheckRedirectPolicy(hostnames ...string) HttpRedirectionPolicy + func FlexibleRedirectPolicy(noOfRedirect int) HttpRedirectionPolicy + func NoRedirectPolicy() HttpRedirectionPolicy + type HttpRedirectionPolicyFunc func(*http.Request, []*http.Request) error + func (f HttpRedirectionPolicyFunc) Apply(req *http.Request, via []*http.Request) error + type HttpRequest 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 *HttpRequest) Context() context.Context + func (r *HttpRequest) Delete(url string) (*HttpResponse, error) + func (r *HttpRequest) EnableTrace() *HttpRequest + func (r *HttpRequest) Execute(method, url string) (*HttpResponse, error) + func (r *HttpRequest) ExpectContentType(contentType string) *HttpRequest + func (r *HttpRequest) ForceContentType(contentType string) *HttpRequest + func (r *HttpRequest) Get(url string) (*HttpResponse, error) + func (r *HttpRequest) Head(url string) (*HttpResponse, error) + func (r *HttpRequest) Options(url string) (*HttpResponse, error) + func (r *HttpRequest) Patch(url string) (*HttpResponse, error) + func (r *HttpRequest) Post(url string) (*HttpResponse, error) + func (r *HttpRequest) Put(url string) (*HttpResponse, error) + func (r *HttpRequest) Send() (*HttpResponse, error) + func (r *HttpRequest) TraceInfo() HttpTracing + func (r *HttpRequest) UseAuthenticationSchema(scheme string) *HttpRequest + func (r *HttpRequest) UseAuthenticationToken(token string) *HttpRequest + func (r *HttpRequest) UseBasicAuthentication(username, password string) *HttpRequest + func (r *HttpRequest) UseBody(body interface{}) *HttpRequest + func (r *HttpRequest) UseContentLength(l bool) *HttpRequest + func (r *HttpRequest) UseContext(ctx context.Context) *HttpRequest + func (r *HttpRequest) UseCookie(hc *http.Cookie) *HttpRequest + func (r *HttpRequest) UseCookies(rs []*http.Cookie) *HttpRequest + func (r *HttpRequest) UseDoNotParseResponse(parse bool) *HttpRequest + func (r *HttpRequest) UseError(err interface{}) *HttpRequest + func (r *HttpRequest) UseFile(param, filePath string) *HttpRequest + func (r *HttpRequest) UseFileReader(param, fileName string, reader io.Reader) *HttpRequest + func (r *HttpRequest) UseFiles(files map[string]string) *HttpRequest + func (r *HttpRequest) UseFormData(data map[string]string) *HttpRequest + func (r *HttpRequest) UseFormDataFromValues(data url.Values) *HttpRequest + func (r *HttpRequest) UseHeader(header, value string) *HttpRequest + func (r *HttpRequest) UseHeaderVerbatim(header, value string) *HttpRequest + func (r *HttpRequest) UseHeaders(headers map[string]string) *HttpRequest + func (r *HttpRequest) UseJSONEscapeHTML(b bool) *HttpRequest + func (r *HttpRequest) UseMultipartField(param, fileName, contentType string, reader io.Reader) *HttpRequest + func (r *HttpRequest) UseMultipartFields(fields ...*MultipartField) *HttpRequest + func (r *HttpRequest) UseMultipartFormData(data map[string]string) *HttpRequest + func (r *HttpRequest) UseOutputFile(file string) *HttpRequest + func (r *HttpRequest) UsePathParam(param, value string) *HttpRequest + func (r *HttpRequest) UsePathParams(params map[string]string) *HttpRequest + func (r *HttpRequest) UseQueryParam(param, value string) *HttpRequest + func (r *HttpRequest) UseQueryParams(params map[string]string) *HttpRequest + func (r *HttpRequest) UseQueryParamsFromValues(params url.Values) *HttpRequest + func (r *HttpRequest) UseQueryString(query string) *HttpRequest + func (r *HttpRequest) UseResponse(res interface{}) *HttpRequest + func (r *HttpRequest) UseSRV(srv *SRVRecord) *HttpRequest + type HttpResponse struct + RawResponse *http.Response + Request *HttpRequest + func (r *HttpResponse) CalculateDuration() time.Duration + func (r *HttpResponse) ExtractBody() []byte + func (r *HttpResponse) ExtractBodyAsString() string + func (r *HttpResponse) ExtractCookies() []*http.Cookie + func (r *HttpResponse) ExtractError() interface{} + func (r *HttpResponse) ExtractHeader() http.Header + func (r *HttpResponse) ExtractProto() string + func (r *HttpResponse) ExtractRawBody() io.ReadCloser + func (r *HttpResponse) ExtractResult() interface{} + func (r *HttpResponse) ExtractStatus() string + func (r *HttpResponse) ExtractStatusCode() int + func (r *HttpResponse) IsError() bool + func (r *HttpResponse) IsSuccess() bool + func (r *HttpResponse) ReceivedAt() time.Time + func (r *HttpResponse) Size() int64 + type HttpTracing 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 MultipartField struct + ContentType string + FileName string + Param string + type OnRetryFunc func(*HttpResponse, 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 RequestLog struct + Body string + Header http.Header + type RequestLogCallback func(*RequestLog) error + type RequestMiddleware func(*HttpClient, *HttpRequest) error + type ResponseError struct + Err error + Response *HttpResponse + 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, *HttpResponse) error + type RetryAfterFunc func(*HttpClient, *HttpResponse) (time.Duration, error) + type RetryConditionFunc func(*HttpResponse, error) bool + type SRVRecord struct + Domain string + Service string + type User struct + Password string + Username string