Documentation ¶
Index ¶
- Constants
- func GetClientConfigKey(name string) string
- type CircuitBreakerSettings
- type CircuitIsOpenError
- type Client
- func NewCircuitBreakerClientWithInterfaces(baseClient Client, logger log.Logger, clock clock.Clock, name string, ...) Client
- func NewHttpClientWithInterfaces(logger log.Logger, clock clock.Clock, metricWriter metric.Writer, ...) Client
- func ProvideHttpClient(ctx context.Context, config cfg.Config, logger log.Logger, name string) (Client, error)
- type Header
- type Request
- func (r *Request) GetBody() interface{}
- func (r *Request) GetError() error
- func (r *Request) GetHeader() Header
- func (r *Request) GetToken() string
- func (r *Request) GetUrl() string
- func (r *Request) WithAuthToken(token string) *Request
- func (r *Request) WithBasicAuth(username string, password string) *Request
- func (r *Request) WithBody(body interface{}) *Request
- func (r *Request) WithHeader(key string, value string) *Request
- func (r *Request) WithMultipartFile(param, fileName string, reader io.Reader) *Request
- func (r *Request) WithMultipartFormData(params url.Values) *Request
- func (r *Request) WithOutputFile(path string) *Request
- func (r *Request) WithQueryMap(values interface{}) *Request
- func (r *Request) WithQueryObject(obj interface{}) *Request
- func (r *Request) WithQueryParam(key string, values ...interface{}) *Request
- func (r *Request) WithUrl(rawUrl string) *Request
- type Response
- type RetryConditionFunc
- type Settings
Constants ¶
View Source
const ( DeleteRequest = "DELETE" GetRequest = "GET" PostRequest = "POST" PutRequest = "PUT" PatchRequest = "PATCH" OptionsRequest = "OPTIONS" )
View Source
const ( AcceptAll = "*/*" AuthorizationTypeBasic = "Basic" AuthorizationTypeBearer = "Bearer" AuthorizationTypeDigest = "Digest" ContentEncodingGzip = "gzip" MimeTypeApplicationFormUrlencoded = "application/x-www-form-urlencoded" MimeTypeApplicationJson = "application/json" MimeTypeApplicationXml = "application/xml" MimeTypeTextCsv = "text/csv" MimeTypeTextPlain = "text/plain" )
Variables ¶
This section is empty.
Functions ¶
func GetClientConfigKey ¶
Types ¶
type CircuitBreakerSettings ¶
type CircuitIsOpenError ¶
type CircuitIsOpenError struct { }
func (CircuitIsOpenError) Error ¶
func (c CircuitIsOpenError) Error() string
type Client ¶
type Client interface { Delete(ctx context.Context, request *Request) (*Response, error) Get(ctx context.Context, request *Request) (*Response, error) Patch(ctx context.Context, request *Request) (*Response, error) Post(ctx context.Context, request *Request) (*Response, error) Put(ctx context.Context, request *Request) (*Response, error) SetTimeout(timeout time.Duration) SetUserAgent(ua string) SetProxyUrl(p string) SetCookies(cs []*http.Cookie) SetCookie(c *http.Cookie) SetRedirectValidator(allowRequest func(request *http.Request) bool) AddRetryCondition(f RetryConditionFunc) NewRequest() *Request NewJsonRequest() *Request NewXmlRequest() *Request }
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewJsonRequest ¶
NewJsonRequest creates a request that already contains the application/json content-type, don't create the object inline!
func NewRequest ¶
NewRequest or client.NewRequest() creates a request, don't create the object inline!
func NewXmlRequest ¶
NewXmlRequest creates a request that already contains the application/xml content-type, don't create the object inline!
func (*Request) WithAuthToken ¶
func (*Request) WithBasicAuth ¶
func (*Request) WithMultipartFile ¶
func (*Request) WithMultipartFormData ¶
func (*Request) WithOutputFile ¶
func (*Request) WithQueryMap ¶
func (*Request) WithQueryObject ¶
func (*Request) WithQueryParam ¶
type RetryConditionFunc ¶
type Settings ¶
type Settings struct { FollowRedirects bool `cfg:"follow_redirects" default:"true"` RequestTimeout time.Duration `cfg:"request_timeout" default:"30s"` RetryCount int `cfg:"retry_count" default:"5"` RetryMaxWaitTime time.Duration `cfg:"retry_max_wait_time" default:"2000ms"` RetryResetReaders bool `cfg:"retry_reset_readers" default:"true"` RetryWaitTime time.Duration `cfg:"retry_wait_time" default:"100ms"` CircuitBreakerSettings CircuitBreakerSettings `cfg:"circuit_breaker"` }
Click to show internal directories.
Click to hide internal directories.