recorder

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2021 License: BSD-2-Clause Imports: 11 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode represents recording/playback mode

const (
	ModeRecording Mode = iota
	ModeReplaying
	ModeDisabled
	// Replay record from cassette or record a new one when a request is not
	// present in cassette instead of throwing ErrInteractionNotFound
	ModeReplayingOrRecording
)

Recorder states

type Passthrough added in v1.1.0

type Passthrough func(*http.Request) bool

Passthrough function allows ignoring certain requests.

type Recorder

type Recorder struct {

	// Pass through requests.
	Passthroughs []Passthrough
	// contains filtered or unexported fields
}

Recorder represents a type used to record and replay client and server interactions

func New

func New(cassetteName string) (*Recorder, error)

New creates a new recorder

func NewAsMode

func NewAsMode(cassetteName string, mode Mode, realTransport http.RoundTripper) (*Recorder, error)

NewAsMode creates a new recorder in the specified mode

func (*Recorder) AddFilter

func (r *Recorder) AddFilter(filter cassette.Filter)

AddFilter appends a hook to modify a request before it is recorded.

Filters are useful for filtering out sensitive parameters from the recorded data.

func (*Recorder) AddPassthrough added in v1.1.0

func (r *Recorder) AddPassthrough(pass Passthrough)

AddPassthrough appends a hook to determine if a request should be ignored by the recorder.

func (*Recorder) AddSaveFilter added in v1.1.0

func (r *Recorder) AddSaveFilter(filter cassette.Filter)

AddSaveFilter appends a hook to modify a request before it is saved.

This filter is suitable for treating recorded responses to remove sensitive data. Altering responses using a regular AddFilter can have unintended consequences on code that is consuming responses.

func (*Recorder) CancelRequest

func (r *Recorder) CancelRequest(req *http.Request)

CancelRequest implements the github.com/coreos/etcd/client.CancelableTransport interface

func (*Recorder) Mode added in v1.1.0

func (r *Recorder) Mode() Mode

Mode returns recorder state

func (*Recorder) RoundTrip

func (r *Recorder) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface

func (*Recorder) SetMatcher

func (r *Recorder) SetMatcher(matcher cassette.Matcher)

SetMatcher sets a function to match requests against recorded HTTP interactions.

func (*Recorder) SetReplayableInteractions added in v1.2.0

func (r *Recorder) SetReplayableInteractions(replayable bool)

SetReplayableInteractions defines whether to allow interactions to be replayed or not.

func (*Recorder) SetTransport

func (r *Recorder) SetTransport(t http.RoundTripper)

SetTransport can be used to configure the behavior of the 'real' client used in record-mode

func (*Recorder) Stop

func (r *Recorder) Stop() error

Stop is used to stop the recorder and save any recorded interactions

Jump to

Keyboard shortcuts

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