httpmonitor

package
v0.0.0-...-ef83997 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exchange

type Exchange struct {
	RequestMethod string
	RequestURL    string
	StatusCode    int
	Error         error
}

Exchange a type to store the request's method and URL and the response's status code

type TransportMonitor

type TransportMonitor struct {
	Exchanges []Exchange
	// contains filtered or unexported fields
}

TransportMonitor is a wrapper around the HTTP client's transport It collects usage stats of the request/responses, to be able to verify what how the HTTP client was actually used.

func NewTransportMonitor

func NewTransportMonitor(t http.RoundTripper) *TransportMonitor

NewTransportMonitor returns a new Transport monitor

func (*TransportMonitor) RoundTrip

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

RoundTrip implements the http.RoundTripper#RoundTrip(*http.Request) (*http.Response, error) function, It delegates the call to the underlying RoundTripper of this monitor, and keps track of the request/response exhanges data.

func (*TransportMonitor) ValidateExchanges

func (t *TransportMonitor) ValidateExchanges(exchanges ...Exchange) error

ValidateExchanges verifies that the transport monitor contains the exact given sequence of exchanges

func (*TransportMonitor) ValidateNoExchanges

func (t *TransportMonitor) ValidateNoExchanges() error

ValidateNoExchanges verifies that the transport monitor does not contain any record of exchanges

Jump to

Keyboard shortcuts

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