func GetURLResponse(url string, trim bool) (string, error)
GetURLResponse returns the HTTP response for the provided URL if the request succeeds
Agent is an http agent
type Agent struct { AgentImplementation // contains filtered or unexported fields }
func NewAgent() *Agent
NewAgent return a new agent with default options
func (a *Agent) Client() *http.Client
Client return an net/http client preconfigured with the agent options
func (a *Agent) Get(url string) (content []byte, err error)
Get returns the body a a GET request
func (a *Agent) GetRequest(url string) (response *http.Response, err error)
GetRequest sends a GET request to a URL and returns the request and response
func (a *Agent) Post(url string, postData []byte) (content []byte, err error)
Post returns the body of a POST request
func (a *Agent) PostRequest(url string, postData []byte) (response *http.Response, err error)
PostRequest sends the postData in a POST request to a URL and returns the request object
func (a *Agent) SetImplementation(impl AgentImplementation)
SetImplementation sets the agent implementation
func (a *Agent) WithFailOnHTTPError(flag bool) *Agent
WithFailOnHTTPError determines if the agent fails on HTTP errors (HTTP status not in 200s)
func (a *Agent) WithRetries(retries uint) *Agent
WithRetries sets the number of times we'll attempt to fetch the URL
func (a *Agent) WithTimeout(timeout time.Duration) *Agent
WithTimeout sets the agent timeout
AgentImplementation is the actual implementation of the http calls
type AgentImplementation interface { SendPostRequest(*http.Client, string, []byte, string) (*http.Response, error) SendGetRequest(*http.Client, string) (*http.Response, error) }