Documentation ¶
Index ¶
- type Error
- type IWebClientOption
- type WebClient
- func (client *WebClient) Deserialize(body []byte, obj interface{}) error
- func (client *WebClient) DoRequest(request *http.Request) (*http.Response, error)
- func (client *WebClient) FromHTTPResponse(err error, resp *http.Response) *Error
- func (client *WebClient) GetBody(reader io.ReadCloser) ([]byte, error)
- func (client *WebClient) GetData(request *http.Request, obj interface{}) error
- func (client *WebClient) NewClientError(original error, message string, args ...interface{}) *Error
- type WithBackoffEnd
- type WithBackoffMaxElapsed
- type WithBackoffStart
- type WithErrorHandler
- type WithRetryCodes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IWebClientOption ¶
type IWebClientOption interface {
Apply(*WebClient)
}
IWebClientOption defines the functionality that will allow the behavior of a WebClient to be modified at construction
type WebClient ¶
type WebClient struct {
// contains filtered or unexported fields
}
WebClient defines an HTTP client that can be used to handle typical JSON responses from an API
func NewWebClient ¶
func NewWebClient(logger *utils.Logger, opts ...IWebClientOption) *WebClient
NewWebClient creates a new connection to an API
func WithClient ¶
WithClient creates a new connection to the API with a given HTTP client
func (*WebClient) Deserialize ¶
Deserialize extracts the respone body JSON into the object provided
func (*WebClient) FromHTTPResponse ¶
FromHTTPResponse creates a new client error from an HTTP response, and an inner error
func (*WebClient) GetBody ¶
func (client *WebClient) GetBody(reader io.ReadCloser) ([]byte, error)
GetBody reads the body from an HTTP response
type WithBackoffEnd ¶
WithBackoffEnd allows the user to set the ending time to use when backing off from an API error that should be retried
func (WithBackoffEnd) Apply ¶
func (w WithBackoffEnd) Apply(client *WebClient)
Apply modifies the WebClient so that it has the end interval defined by this object
type WithBackoffMaxElapsed ¶
WithBackoffMaxElapsed allows the user to set the maximum time that should be allowed when the API returns an error that should be retried
func (WithBackoffMaxElapsed) Apply ¶
func (w WithBackoffMaxElapsed) Apply(client *WebClient)
Apply modifies the WebClient so that it has the maximum interval defined by this object
type WithBackoffStart ¶
WithBackoffStart allows the user to set the starting time to use when backing off from an API error that should be retried
func (WithBackoffStart) Apply ¶
func (w WithBackoffStart) Apply(client *WebClient)
Apply modifies the WebClient so that it has the start interval defined by this object
type WithErrorHandler ¶
WithErrorHandler allows the user to set the error handler function that is called when an API request returns a bad response
func (WithErrorHandler) Apply ¶
func (w WithErrorHandler) Apply(client *WebClient)
Apply modifies the WebClient so that it has the error handler defined by this object
type WithRetryCodes ¶
type WithRetryCodes []int
WithRetryCodes allows the user to define the HTTP status codes that would trigger a retry of the API endpoint rather than generating an error
func (WithRetryCodes) Apply ¶
func (w WithRetryCodes) Apply(client *WebClient)
Apply modifies the WebClient so that it has the retry codes defined by this object