Documentation ¶
Index ¶
- func CreateMultipartHeader(param, fileName, contentType string) textproto.MIMEHeader
- func IsValidMultipartVerb(method string) (err error)
- func WriteMultipartFormFile(w *multipart.Writer, fieldName, fileName string, r io.Reader) error
- type Client
- func (c *Client) AddCodecOption(k string, v interface{}) *Client
- func (c *Client) Close() (err error)
- func (c *Client) ErrorOnHttpStatus(statusCodes ...int) *Client
- func (c *Client) Execute(req *Request) (res *Response, err error)
- func (c *Client) IdleTimeout(t uint) *Client
- func (c *Client) MaxIdle(maxIdleConn int) *Client
- func (c *Client) MaxIdlePerHost(maxIdleConnPerHost int) *Client
- func (c *Client) NewRequest(url, method string) *Request
- func (c *Client) ReqTimeout(t uint) *Client
- func (c *Client) Retry(maxRetries, wait int) *Client
- func (c *Client) SSlVerify(verify bool) (*Client, error)
- func (c *Client) SetCACerts(caFilePath ...string) (*Client, error)
- func (c *Client) SetProxy(proxyUrl, user, password string) (err error)
- func (c *Client) SetTLSCerts(certs ...tls.Certificate) (*Client, error)
- func (c *Client) UseCircuitBreaker(failureThreshold, successThreshold uint64, maxHalfOpen, timeout uint32) *Client
- func (c *Client) UseEnvProxy(urlParam, userParam, passwdParam string) (err error)
- type MultipartFile
- type Request
- func (r *Request) AddFormData(k string, v ...string) *Request
- func (r *Request) AddHeader(k string, v ...string) *Request
- func (r *Request) AddPathParam(k string, v string) *Request
- func (r *Request) AddQueryParam(k string, v ...string) *Request
- func (r *Request) Method() string
- func (r *Request) SeBodyReader(reader io.Reader) *Request
- func (r *Request) SetBody(v interface{}) *Request
- func (r *Request) SetContentType(contentType string) *Request
- func (r *Request) SetMultipartFiles(files ...*MultipartFile) *Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMultipartHeader ¶
func CreateMultipartHeader(param, fileName, contentType string) textproto.MIMEHeader
CreateMultipartHeader creates a multipart header with the given parameters
func IsValidMultipartVerb ¶
IsValidMultipartVerb checks if the method is valid for multipart content
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a REST client.
func (*Client) AddCodecOption ¶
AddCodecOption sets the option for the codec to be used.
func (*Client) ErrorOnHttpStatus ¶
ErrorOnHttpStatus sets the list of status codes that can be considered failures. This is useful for QualityOfService features like CircuitBreaker.
func (*Client) IdleTimeout ¶
IdleTimeout sets the maximum amount of time a connection can stay idle (keep-alive) before closing itself.
func (*Client) MaxIdle ¶
MaxIdle sets the maximum number of idle connections that can stay idle (keep-alive).
func (*Client) MaxIdlePerHost ¶
MaxIdlePerHost sets the maximum number of idle connections that can stay idle (keep-alive) for a given hostname.
func (*Client) NewRequest ¶
NewRequest creates a new request object for the client.
func (*Client) ReqTimeout ¶
ReqTimeout sets the overall client timeout for a request. The default value is 60 seconds.
func (*Client) Retry ¶
Retry sets the maximum number of retries and wait interval in seconds between retries. The client does not retry by default. If retry configuration is set along with UseCircuitBreaker, then the retry config is ignored.
func (*Client) SetCACerts ¶
SetCACerts sets the CA certificates for the client.
func (*Client) SetTLSCerts ¶
func (c *Client) SetTLSCerts(certs ...tls.Certificate) (*Client, error)
SetTLSCerts sets the client certificate key pair for the client.
func (*Client) UseCircuitBreaker ¶
func (c *Client) UseCircuitBreaker(failureThreshold, successThreshold uint64, maxHalfOpen, timeout uint32) *Client
UseCircuitBreaker sets the circuit breaker configuration for this client. The circuit breaker pattern has higher precedence than the retry pattern. If both are set, then the retry configuration is ignored.
func (*Client) UseEnvProxy ¶
UseEnvProxy ensures that the proxy settings are loaded using environment parameters.
type MultipartFile ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request struct holds the http Request for the rest client
func (*Request) AddFormData ¶
AddFormData function adds the form data with the name specified by k list of values in order as specified in v If the key does not exist then it creates a new form data by calling url.Values.Set() function on the first key and the value Setting form data will have precedence over to setting body directly.
func (*Request) AddPathParam ¶
AddPathParam function adds the path parameter with key as the name of the parameter and v as the value of the parameter that needs to be replaced
func (*Request) AddQueryParam ¶
AddQueryParam function adds the query parameter with the name specified by k list of values in order as specified in v If the key does not exist then it creates a new form data by calling url.Values.Set() function passing the first key and value
func (*Request) SetContentType ¶
func (*Request) SetMultipartFiles ¶
func (r *Request) SetMultipartFiles(files ...*MultipartFile) *Request
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) Decode ¶
Decode Function decodes the response body to a suitable object. The format of the body is determined by Content-Type header in the response
func (*Response) StatusCode ¶
StatusCode provides the status code of the response