Documentation ¶
Index ¶
Constants ¶
View Source
const ( QueryParam = "queries" HeaderParam = "headers" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Get(targetURL string, opts SendOptions) (*Response, error) Put(targetURL string, opts SendOptions, body []byte) (*Response, error) Post(targetURL string, opts SendOptions, body []byte) (*Response, error) Patch(targetURL string, opts SendOptions, body []byte) (*Response, error) Delete(targetURL string, opts SendOptions, body []byte) (*Response, error) Send(method, path string, opts SendOptions, body []byte) (*Response, error) GetStandardClient() *http.Client }
Client provided for mock
func NewClientWithDebug ¶
func NewClientWithDebug(debugEnable bool, optsClient ...OptionClient) Client
NewClientWithDebug init http client with debug config
type OptionClient ¶
type OptionClient func(*retryablehttp.Client)
OptionClient represents an option for the http client
func WithRetryMax ¶
func WithRetryMax(retryMax int) OptionClient
WithRetryMax sets max retry of the client options
func WithTimeout ¶
func WithTimeout(timeout time.Duration) OptionClient
WithTimeout sets timeout of the client options
type SendOptions ¶
SendOptions for attached data through a request Example should be add query params (http://abcd.com?user=ec&limit=5) or header
SendOptions { "queries": map[string]interface{}{ "user": "ec", "limit": "5", }, "headers": map[string]interface{}{ "xxx": "abc", "Content-Type": "application/json", }, }
func (SendOptions) SetContentType ¶
func (opt SendOptions) SetContentType(t string) SendOptions
SetContentType sets a content type of the request
func (SendOptions) SetQueryParam ¶
func (opt SendOptions) SetQueryParam(params map[string]interface{}) SendOptions
SetContentType sets query params of the request
Click to show internal directories.
Click to hide internal directories.