Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewHTTPClient = defaultHTTPClientFactory

NewHTTPClient is a factory of HTTPClient

Functions

func GetTransport

func GetTransport(opts ...func(*http.Transport) error) (http.RoundTripper, error)

func UnmarshalResponse

func UnmarshalResponse(resp *http.Response) (interface{}, interface{}, error)

UnmarshalResponse takes an http Response and returns: - its body, deserialized if content-type appropriate - metadata such as headers and status code

func WithTLSClientAuth

func WithTLSClientAuth(cert tls.Certificate) func(*http.Transport) error

func WithTLSInsecureSkipVerify

func WithTLSInsecureSkipVerify(v bool) func(*http.Transport) error

func WithTLSRootCA

func WithTLSRootCA(caCert []byte) func(*http.Transport) error

WithTLSRootCA should be called only once, with multiple PEM encoded certificates as input if needed.

Types

type HTTPClient

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

HTTPClient is an interface for decoupling http.Client

type HTTPClientConfig

type HTTPClientConfig struct {
	Timeout        time.Duration
	FollowRedirect bool
	Transport      http.RoundTripper
}

HTTPClientConfig is a set of options used to initialize a HTTPClient

type UnmarshalFunc

type UnmarshalFunc func(action []byte, values interface{}) error

UnmarshalFunc is a type of function capable of taking the body of an http response and deserialize it into a target interface{}

Source Files