Documentation

Index

Constants

View Source
const (
	// Profile is a http client profile.
	Profile = "httpclient"
)

Variables

This section is empty.

Functions

func Delete

func Delete(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)

    Delete makes a HTTP DELETE request with provided URL with default client

    func Get

    func Get(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)

      Get makes a HTTP GET request to provided URL with default client

      func NewClient

      func NewClient(opts ...Option) *client

        NewClient returns a new instance of http client

        func Patch

        func Patch(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)

          Patch makes a HTTP PATCH request to provided URL and requestBody with default client

          func Post

          func Post(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)

            Post makes a HTTP POST request to provided URL and requestBody with default client

            func Put

            func Put(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)

              Put makes a HTTP PUT request to provided URL and requestBody with default client

              Types

              type Backoff

              type Backoff interface {
              	Next(retry int) time.Duration
              }

                Backoff interface defines contract for backoff strategies

                func NewConstantBackoff

                func NewConstantBackoff(backoffInterval, maximumJitterInterval time.Duration) Backoff

                  NewConstantBackoff returns an instance of ConstantBackoff

                  func NewExponentialBackoff

                  func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration, exponentFactor float64, maximumJitterInterval time.Duration) Backoff

                    NewExponentialBackoff returns an instance of ExponentialBackoff

                    type Client

                    type Client interface {
                    	Get(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
                    	Post(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
                    	Put(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
                    	Patch(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
                    	Delete(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
                    	Do(req *http.Request) (*http.Response, error)
                    }

                      Client Is a generic HTTP client interface

                      type Doer

                      type Doer interface {
                      	Do(*http.Request) (*http.Response, error)
                      }

                        Doer interface has the method required to use a type as custom http client. The net/*http.client type satisfies this interface.

                        type Option

                        type Option func(*client)

                          Option represents the client options

                          func WithHTTPClient

                          func WithHTTPClient(doer Doer) Option

                            WithHTTPClient sets a custom http client

                            func WithHTTPTimeout

                            func WithHTTPTimeout(timeout time.Duration) Option

                              WithHTTPTimeout sets hystrix timeout

                              func WithRetrier

                              func WithRetrier(retrier Retriable) Option

                                WithRetrier sets the strategy for retrying

                                func WithRetryCount

                                func WithRetryCount(retryCount int) Option

                                  WithRetryCount sets the retrier count for the hystrixHTTPClient

                                  type Retriable

                                  type Retriable interface {
                                  	NextInterval(retry int) time.Duration
                                  }

                                    Retriable defines contract for retriers to implement

                                    func NewNoRetrier

                                    func NewNoRetrier() Retriable

                                      NewNoRetrier returns a null object for retriable

                                      func NewRetrier

                                      func NewRetrier(backoff Backoff) Retriable

                                        NewRetrier returns retrier with some backoff strategy

                                        func NewRetrierFunc

                                        func NewRetrierFunc(f RetriableFunc) Retriable

                                          NewRetrierFunc returns a retrier with a retrier function defined

                                          type RetriableFunc

                                          type RetriableFunc func(retry int) time.Duration

                                            RetriableFunc is an adapter to allow the use of ordinary functions as a Retriable

                                            func (RetriableFunc) NextInterval

                                            func (f RetriableFunc) NextInterval(retry int) time.Duration

                                              NextInterval calls f(retrier)

                                              Directories

                                              Path Synopsis