http

package
v0.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetURLResponse

func GetURLResponse(url string, trim bool) (string, error)

GetURLResponse returns the HTTP response for the provided URL if the request succeeds

Types

type Agent added in v0.2.0

type Agent struct {
	AgentImplementation
	// contains filtered or unexported fields
}

Agent is an http agent

func NewAgent added in v0.2.0

func NewAgent() *Agent

NewAgent return a new agent with default options

func (*Agent) Client added in v0.2.0

func (a *Agent) Client() *http.Client

Client return an net/http client preconfigured with the agent options

func (*Agent) Get added in v0.2.0

func (a *Agent) Get(url string) (content []byte, err error)

Get returns the body a a GET request

func (*Agent) GetRequest added in v0.2.0

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 (*Agent) Post added in v0.2.0

func (a *Agent) Post(url string, postData []byte) (content []byte, err error)

Post returns the body of a POST request

func (*Agent) PostRequest added in v0.2.0

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 (*Agent) SetImplementation added in v0.2.0

func (a *Agent) SetImplementation(impl AgentImplementation)

SetImplementation sets the agent implementation

func (*Agent) WithFailOnHTTPError added in v0.2.0

func (a *Agent) WithFailOnHTTPError(flag bool) *Agent

WithFailOnHTTPError determines if the agent fails on HTTP errors (HTTP status not in 200s)

func (*Agent) WithRetries added in v0.2.0

func (a *Agent) WithRetries(retries uint) *Agent

WithRetries sets the number of times we'll attempt to fetch the URL

func (*Agent) WithTimeout added in v0.2.0

func (a *Agent) WithTimeout(timeout time.Duration) *Agent

WithTimeout sets the agent timeout

type AgentImplementation added in v0.2.0

type AgentImplementation interface {
	SendPostRequest(*http.Client, string, []byte, string) (*http.Response, error)
	SendGetRequest(*http.Client, string) (*http.Response, error)
}

AgentImplementation is the actual implementation of the http calls

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL