Documentation ¶
Overview ¶
Package requestor contains the methods to make HTTP requests to different endpoints
Package requestor contains the methods to make HTTP requests to different endpoints
Index ¶
- type Client
- func (c *Client) Connect(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
- func (c *Client) Delete(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
- func (c *Client) DisableKeepAlive(val bool)
- func (c *Client) Get(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
- func (c *Client) Head(url string) (response *http.Response, err error)
- func (c *Client) Options(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
- func (c *Client) Patch(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
- func (c *Client) Post(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
- func (c *Client) Put(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
- func (c *Client) SetHTTPProxy(proxyURL, username, password string)
- func (c *Client) SetHTTPSProxy(proxyURL, username, password string)
- func (c *Client) SetIdleConnectionTimeout(timeout time.Duration)
- func (c *Client) SetMaxConnectionsPerHost(connectionCount int)
- func (c *Client) SetMaxIdleConnections(connectionCount int)
- func (c *Client) SetMaxIdleConnectionsPerHost(connectionCount int)
- func (c *Client) SetMaxRetries(retries uint8, timeBetweenRetries int64)
- func (c *Client) SetTLSClientConfig(tlsConfig *tls.Config)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) Trace(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // MaxRetriesOnError specifies how many times we should retry when a request to server fails MaxRetriesOnError uint8 // TimeBetweenRetries specifies the amount of time between each retry TimeBetweenRetries int64 // Timeout specifies a time limit for requests made by this // Client. The timeout includes connection time, any // redirects, and reading the response body. The timer remains // running after Get, Head, Post, or Do return and will // interrupt reading of the Response.Body. // // A Timeout of zero means no timeout. // The Client cancels requests to the underlying Transport // as if the Request's Context ended. Timeout time.Duration // IdleConnectionTimeout specifies how long an idle connection is kept in the connection pool // 0 means no timeout IdleConnectionTimeout time.Duration // MaxConnectionsPerHost specifies the max number of connection per host which include connections in dialing // active and idle states. When exceeded request gets cancelled with net/http: request canceled. // 0 means no limit MaxConnectionsPerHost int // MaxIdleConnectionsPerHost specifies the max number of keep-alive connections per host MaxIdleConnectionsPerHost int // MaxIdleConnections specifies the max number of keep-alive connections MaxIdleConnections int // DisableKeepAlives makes sure that the transport is used only once by disabling keep-alives // Default is true DisableKeepAlives bool // TLSClientConfig specifies the TLS config to use TLSClientConfig *tls.Config // contains filtered or unexported fields }
Client here is a struct that holds different configurations to tune Requestor
func (*Client) Connect ¶
func (c *Client) Connect(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
Connect performs a HTTP CONNECT request. It takes in a URL, user specified headers, query params and returns Response error if exist
func (*Client) Delete ¶
func (c *Client) Delete(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
Delete performs a HTTP DELETE request. It takes in a URL, user specified headers, query params, data and returns Response and error if exist
func (*Client) DisableKeepAlive ¶
DisableKeepAlive sets keep-alive to either true/false
func (*Client) Get ¶
func (c *Client) Get(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
Get performs a HTTP GET request. It takes in a URL, user specified headers, query params and returns Response and error if exist
func (*Client) Head ¶
Head performs a HTTP HEAD request. It takes in a URL, user specified headers, query params and returns Response and error if exist
func (*Client) Options ¶
func (c *Client) Options(url string, headers, queryParams map[string][]string) (response *http.Response, err error)
Options performs a HTTP Options request. It takes in a URL, user specified headers, query params and returns Response and error if exist
func (*Client) Patch ¶
func (c *Client) Patch(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
Patch performs a HTTP PATCH request. It takes in a URL, user specified headers, query params, data and returns Response and error if exist
func (*Client) Post ¶
func (c *Client) Post(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
Post performs a HTTP POST request. It takes in a URL, user specified headers, query params, data and returns Response and error if exist
func (*Client) Put ¶
func (c *Client) Put(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error)
Put performs a HTTP PUT request. It takes in a URL, user specified headers, query params, data and returns Response and error if exist
func (*Client) SetHTTPProxy ¶
SetHTTPProxy sets a HTTP proxy to the transport, proxyURL is a required parameter, but username and password is optional parameters. Proxy URL should be of format IP:PORT or HOSTNAME:PORT
func (*Client) SetHTTPSProxy ¶
SetHTTPSProxy sets a HTTP proxy to the transport, proxyURL is a required parameter, but username and password is optional parameters. Proxy URL should be of format IP:PORT or HOSTNAME:PORT
func (*Client) SetIdleConnectionTimeout ¶
SetIdleConnectionTimeout sets the idle connection timeout
func (*Client) SetMaxConnectionsPerHost ¶
SetMaxConnectionsPerHost sets the max connections per host
func (*Client) SetMaxIdleConnections ¶
SetMaxIdleConnections sets the max idle connections
func (*Client) SetMaxIdleConnectionsPerHost ¶
SetMaxIdleConnectionsPerHost sets the max idle connections per host
func (*Client) SetMaxRetries ¶
SetMaxRetries sets the max amount of retries and the time between them in seconds
func (*Client) SetTLSClientConfig ¶
SetTLSClientConfig attaches custom client tls config to Transport
func (*Client) SetTimeout ¶
SetTimeout sets timeout to request