httputils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoggingTransport

type LoggingTransport struct {
	RoundTrips []*RoundTrip
	// contains filtered or unexported fields
}

LoggingTransport is a transport which keeps track of all requests and responses

func NewLoggingTransport

func NewLoggingTransport(tripper http.RoundTripper) *LoggingTransport

NewLoggingTransport creates a new logging transport

func (*LoggingTransport) RoundTrip

func (t *LoggingTransport) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip satisfier the roundtripper interface in http to allow for capturing requests and responses of the parent http client.

type RoundTrip

type RoundTrip struct {
	Method       string
	URL          string
	RequestBody  []byte
	Status       int
	ResponseBody []byte
	StartedOn    time.Time
	Elapsed      time.Duration
}

RoundTrip represents a single request / response round trip created by our transport. In the case of connection errors, the status code will be set to 499 and the response body will contain more information about the error encountered

type UserAgentTransport

type UserAgentTransport struct {
	// contains filtered or unexported fields
}

UserAgentTransport just injects a custom user agent on the request before sending it out

func NewUserAgentTransport

func NewUserAgentTransport(tripper http.RoundTripper, agent string) *UserAgentTransport

NewUserAgentTransport creates a new transport that injects a user agent in all requests

func (*UserAgentTransport) RoundTrip

func (t *UserAgentTransport) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip just injects our custom user agent, passing the request down the chain

Jump to

Keyboard shortcuts

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