httpclient

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = time.Second * 15
)

Variables

This section is empty.

Functions

func DefaultHttpClient

func DefaultHttpClient() *http.Client

DefaultClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.

func DefaultPooledClient

func DefaultPooledClient() *http.Client

DefaultPooledClient returns a new http.Client with the same default values as http.Client, but with a shared Transport. Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).

func DefaultPooledTransport

func DefaultPooledTransport() *http.Transport

DefaultPooledTransport returns a new http.Transport with similar default values to http.DefaultTransport. Do not use this for transient transports as it can leak file descriptors over time. Only use this for transports that will be re-used for the same host(s).

func DefaultTransport

func DefaultTransport() *http.Transport

TODO learn more from https://github.com/hashicorp/go-cleanhttp DefaultTransport returns a new http.Transport with the same default values as http.DefaultTransport, but with idle connections and keepalives disabled.

Types

type Client

type Client struct {
	HttpClient        *http.Client
	TLSConfig         *tls.Config
	CustomHTTPHeaders map[string]string
}

func NewClient

func NewClient(httpClient *http.Client, customHeaders map[string]string) *Client

func NewDefaultClient

func NewDefaultClient() *Client

func NewTLSClient

func NewTLSClient(tlsCaCert, tlsCert, tlsKey string, httpClient *http.Client, customHeaders map[string]string) (*Client, error)

func (*Client) DELETE

func (cli *Client) DELETE(ctx context.Context, requestUrl string, query url.Values, headers map[string][]string) ([]byte, error)

func (*Client) GET

func (cli *Client) GET(ctx context.Context, requestUrl string, query url.Values, headers map[string][]string) ([]byte, error)

func (*Client) PATCH

func (cli *Client) PATCH(ctx context.Context, requestUrl string, query url.Values, obj interface{}, headers map[string][]string) ([]byte, error)

func (*Client) POST

func (cli *Client) POST(ctx context.Context, requestUrl string, query url.Values, obj interface{}, headers map[string][]string) ([]byte, error)

func (*Client) PUT

func (cli *Client) PUT(ctx context.Context, requestUrl string, query url.Values, obj interface{}, headers map[string][]string) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL