Documentation
¶
Index ¶
- func DefaultBodyMatcher(httpRequest, trackRequest *track.Request) bool
- func DefaultHeaderMatcher(httpRequest, trackRequest *track.Request) bool
- func DefaultMethodMatcher(httpRequest, trackRequest *track.Request) bool
- func DefaultTrailerMatcher(httpRequest, trackRequest *track.Request) bool
- func DefaultURLMatcher(httpRequest, trackRequest *track.Request) bool
- type CassetteLoader
- type ControlPanel
- func (controlPanel *ControlPanel) AddRecordingMutators(trackMutators ...track.Mutator)
- func (controlPanel *ControlPanel) AddReplayingMutators(trackMutators ...track.Mutator)
- func (controlPanel *ControlPanel) AddRequestMatchers(requestMatcher ...RequestMatcher)
- func (controlPanel *ControlPanel) ClearRecordingMutators()
- func (controlPanel *ControlPanel) ClearReplayingMutators()
- func (controlPanel *ControlPanel) HTTPClient() *http.Client
- func (controlPanel *ControlPanel) NumberOfTracks() int32
- func (controlPanel *ControlPanel) SetCipher(crypter CrypterProvider, keyFile string) error
- func (controlPanel *ControlPanel) SetLiveOnlyMode()
- func (controlPanel *ControlPanel) SetNormalMode()
- func (controlPanel *ControlPanel) SetOfflineMode()
- func (controlPanel *ControlPanel) SetReadOnlyMode(state bool)
- func (controlPanel *ControlPanel) SetRecordingMutators(trackMutators ...track.Mutator)
- func (controlPanel *ControlPanel) SetReplayingMutators(trackMutators ...track.Mutator)
- func (controlPanel *ControlPanel) SetRequestMatchers(requestMatcher ...RequestMatcher)
- func (controlPanel *ControlPanel) Stats() *stats.Stats
- type CrypterNonceProvider
- type CrypterProvider
- type HTTPMode
- type PrintedCircuitBoard
- func (pcb *PrintedCircuitBoard) AddRecordingMutators(mutators ...track.Mutator)
- func (pcb *PrintedCircuitBoard) AddReplayingMutators(mutators ...track.Mutator)
- func (pcb *PrintedCircuitBoard) AddRequestMatchers(requestMatchers ...RequestMatcher)
- func (pcb *PrintedCircuitBoard) ClearRecordingMutators()
- func (pcb *PrintedCircuitBoard) ClearReplayingMutators()
- func (pcb *PrintedCircuitBoard) SeekTrack(k7 *cassette.Cassette, httpRequest *http.Request) (*track.Track, error)
- func (pcb *PrintedCircuitBoard) SetLiveOnlyMode()
- func (pcb *PrintedCircuitBoard) SetNormalMode()
- func (pcb *PrintedCircuitBoard) SetOfflineMode()
- func (pcb *PrintedCircuitBoard) SetReadOnlyMode(state bool)
- func (pcb *PrintedCircuitBoard) SetRecordingMutators(trackMutators ...track.Mutator)
- func (pcb *PrintedCircuitBoard) SetReplayingMutators(trackMutators ...track.Mutator)
- func (pcb *PrintedCircuitBoard) SetRequestMatchers(requestMatchers ...RequestMatcher)
- type RequestMatcher
- type RequestMatchers
- type Setting
- func WithClient(httpClient *http.Client) Setting
- func WithLiveOnlyMode() Setting
- func WithOfflineMode() Setting
- func WithReadOnlyMode() Setting
- func WithRequestMatchers(reqMatchers ...RequestMatcher) Setting
- func WithTrackRecordingMutators(trackRecordingMutators ...track.Mutator) Setting
- func WithTrackReplayingMutators(trackReplayingMutators ...track.Mutator) Setting
- type VCRSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBodyMatcher ¶
DefaultBodyMatcher is the default implementation of BodyMatcher.
func DefaultHeaderMatcher ¶
DefaultHeaderMatcher is the default implementation of HeaderMatcher.
func DefaultMethodMatcher ¶
DefaultMethodMatcher is the default implementation of MethodMatcher.
func DefaultTrailerMatcher ¶
DefaultTrailerMatcher is the default implementation of TrailerMatcher.
func DefaultURLMatcher ¶
DefaultURLMatcher is the default implementation of URLMatcher. nolint:gocyclo,gocognit
Types ¶
type CassetteLoader ¶
type CassetteLoader struct {
// contains filtered or unexported fields
}
CassetteLoader helps build a cassette to load in the VCR.
func NewCassetteLoader ¶
func NewCassetteLoader(cassetteName string) *CassetteLoader
NewCassetteLoader creates a new CassetteLoader, initialised with the cassette's name.
func (*CassetteLoader) WithCipher ¶
func (cb *CassetteLoader) WithCipher(crypter CrypterProvider, keyFile string) *CassetteLoader
WithCipher creates a cassette cryptographer with the specified cipher function and key file. Using more than one WithCipher* on the same cassette is ambiguous.
func (*CassetteLoader) WithCipherCustomNonce ¶
func (cb *CassetteLoader) WithCipherCustomNonce(crypterNonce CrypterNonceProvider, keyFile string, nonceGenerator encryption.NonceGenerator) *CassetteLoader
WithCipherCustomNonce creates a cassette cryptographer with the specified key file and customer nonce generator. Using more than one WithCipher* on the same cassette is ambiguous.
func (*CassetteLoader) WithStore ¶
func (cb *CassetteLoader) WithStore(store cassette.FileIO) *CassetteLoader
WithStore creates a cassette in a specific storeage backedn. Using more than one WithStore on the same cassette is ambiguous.
type ControlPanel ¶
type ControlPanel struct {
// contains filtered or unexported fields
}
ControlPanel holds the parts of a VCR that can be interacted with.
func NewVCR ¶
func NewVCR(cassetteLoader *CassetteLoader, settings ...Setting) *ControlPanel
NewVCR creates a new VCR.
func (*ControlPanel) AddRecordingMutators ¶
func (controlPanel *ControlPanel) AddRecordingMutators(trackMutators ...track.Mutator)
AddRecordingMutators adds a set of recording Track Mutator's to the VCR.
func (*ControlPanel) AddReplayingMutators ¶
func (controlPanel *ControlPanel) AddReplayingMutators(trackMutators ...track.Mutator)
AddReplayingMutators adds a set of replaying Track Mutator's to the VCR. Replaying happens AFTER the request has been matched. As such, while the track's Request could be mutated, it will have no effect. However, the Request data can be referenced as part of mutating the Response.
func (*ControlPanel) AddRequestMatchers ¶
func (controlPanel *ControlPanel) AddRequestMatchers(requestMatcher ...RequestMatcher)
AddRequestMatchers sets a new set of RequestMatcher's to the VCR.
func (*ControlPanel) ClearRecordingMutators ¶
func (controlPanel *ControlPanel) ClearRecordingMutators()
ClearRecordingMutators clears the set of recording Track Mutator's from the VCR.
func (*ControlPanel) ClearReplayingMutators ¶
func (controlPanel *ControlPanel) ClearReplayingMutators()
ClearReplayingMutators clears the set of replaying Track Mutator's from the VCR.
func (*ControlPanel) HTTPClient ¶
func (controlPanel *ControlPanel) HTTPClient() *http.Client
HTTPClient returns the http.Client that contains the VCR.
func (*ControlPanel) NumberOfTracks ¶
func (controlPanel *ControlPanel) NumberOfTracks() int32
NumberOfTracks returns the number of tracks contained in the cassette.
func (*ControlPanel) SetCipher ¶
func (controlPanel *ControlPanel) SetCipher(crypter CrypterProvider, keyFile string) error
SetCipher sets the cassette Cipher. This can be used to set a cipher when none is present (which already happens automatically when loading a cassette) or change the cipher when one is already present. The cassette is automatically saved with the new selected cipher.
func (*ControlPanel) SetLiveOnlyMode ¶
func (controlPanel *ControlPanel) SetLiveOnlyMode()
SetLiveOnlyMode sets the VCR to live-only mode.
func (*ControlPanel) SetNormalMode ¶
func (controlPanel *ControlPanel) SetNormalMode()
SetNormalMode sets the VCR to normal HTTP mode.
func (*ControlPanel) SetOfflineMode ¶
func (controlPanel *ControlPanel) SetOfflineMode()
SetOfflineMode sets the VCR to offline mode.
func (*ControlPanel) SetReadOnlyMode ¶
func (controlPanel *ControlPanel) SetReadOnlyMode(state bool)
SetReadOnlyMode sets the VCR to read-only mode (true) or to normal read-write (false).
func (*ControlPanel) SetRecordingMutators ¶
func (controlPanel *ControlPanel) SetRecordingMutators(trackMutators ...track.Mutator)
SetRecordingMutators replaces the set of recording Track Mutator's in the VCR.
func (*ControlPanel) SetReplayingMutators ¶
func (controlPanel *ControlPanel) SetReplayingMutators(trackMutators ...track.Mutator)
SetReplayingMutators replaces the set of replaying Track Mutator's in the VCR.
func (*ControlPanel) SetRequestMatchers ¶
func (controlPanel *ControlPanel) SetRequestMatchers(requestMatcher ...RequestMatcher)
SetRequestMatchers sets a new set of RequestMatcher's to the VCR.
func (*ControlPanel) Stats ¶
func (controlPanel *ControlPanel) Stats() *stats.Stats
Stats returns Stats about the cassette and VCR session.
type CrypterNonceProvider ¶
type CrypterNonceProvider func(key []byte, nonceGenerator encryption.NonceGenerator) (*encryption.Crypter, error)
CrypterNonceProvider is the signature of a cipher provider function with custom nonce generator. Examples are encryption.NewAESGCM and encryption.NewChaCha20Poly1305.
type CrypterProvider ¶
type CrypterProvider func(key []byte) (*encryption.Crypter, error)
CrypterProvider is the signature of a cipher provider function with default nonce generator. Examples are encryption.NewAESGCMWithRandomNonceGenerator and encryption.NewChaCha20Poly1305WithRandomNonceGenerator.
type HTTPMode ¶
type HTTPMode int
HTTPMode defines govcr's mode for HTTP requests. See specific modes for further details.
const ( // HTTPModeNormal replays from cassette if a match exists or execute live request. HTTPModeNormal HTTPMode = iota // HTTPModeLiveOnly executes live calls for all requests, ignores cassette. HTTPModeLiveOnly // HTTPModeOffline, plays back from cassette or if no match, return a transport error. HTTPModeOffline )
type PrintedCircuitBoard ¶
type PrintedCircuitBoard struct {
// contains filtered or unexported fields
}
PrintedCircuitBoard is a structure that holds some facilities that are passed to the VCR machine to influence its internal behaviour.
func (*PrintedCircuitBoard) AddRecordingMutators ¶
func (pcb *PrintedCircuitBoard) AddRecordingMutators(mutators ...track.Mutator)
AddRecordingMutators adds a collection of recording TrackMutator's.
func (*PrintedCircuitBoard) AddReplayingMutators ¶
func (pcb *PrintedCircuitBoard) AddReplayingMutators(mutators ...track.Mutator)
AddReplayingMutators adds a collection of replaying TrackMutator's. Replaying happens AFTER the request has been matched. As such, while the track's Request could be mutated, it will have no effect. However, the Request data can be referenced as part of mutating the Response.
func (*PrintedCircuitBoard) AddRequestMatchers ¶
func (pcb *PrintedCircuitBoard) AddRequestMatchers(requestMatchers ...RequestMatcher)
AddRequestMatchers adds a collection of RequestMatcher's.
func (*PrintedCircuitBoard) ClearRecordingMutators ¶
func (pcb *PrintedCircuitBoard) ClearRecordingMutators()
ClearRecordingMutators clears the set of recording Track Mutator's from the VCR.
func (*PrintedCircuitBoard) ClearReplayingMutators ¶
func (pcb *PrintedCircuitBoard) ClearReplayingMutators()
ClearReplayingMutators clears the set of replaying Track Mutator's from the VCR.
func (*PrintedCircuitBoard) SetLiveOnlyMode ¶
func (pcb *PrintedCircuitBoard) SetLiveOnlyMode()
SetLiveOnlyMode sets the VCR to live-only mode.
func (*PrintedCircuitBoard) SetNormalMode ¶
func (pcb *PrintedCircuitBoard) SetNormalMode()
SetNormalMode sets the VCR to normal HTTP mode.
func (*PrintedCircuitBoard) SetOfflineMode ¶
func (pcb *PrintedCircuitBoard) SetOfflineMode()
SetOfflineMode sets the VCR to offline mode.
func (*PrintedCircuitBoard) SetReadOnlyMode ¶
func (pcb *PrintedCircuitBoard) SetReadOnlyMode(state bool)
SetReadOnlyMode sets the VCR to read-only mode (true) or to normal read-write (false).
func (*PrintedCircuitBoard) SetRecordingMutators ¶
func (pcb *PrintedCircuitBoard) SetRecordingMutators(trackMutators ...track.Mutator)
SetRecordingMutators replaces the set of recording Track Mutator's in the VCR.
func (*PrintedCircuitBoard) SetReplayingMutators ¶
func (pcb *PrintedCircuitBoard) SetReplayingMutators(trackMutators ...track.Mutator)
SetReplayingMutators replaces the set of replaying Track Mutator's in the VCR.
func (*PrintedCircuitBoard) SetRequestMatchers ¶
func (pcb *PrintedCircuitBoard) SetRequestMatchers(requestMatchers ...RequestMatcher)
SetRequestMatchers sets a collection of RequestMatcher's.
type RequestMatcher ¶
RequestMatcher is a function that performs request comparison. request comparison involves the HTTP request and the track request recorded on cassette.
type RequestMatchers ¶
type RequestMatchers []RequestMatcher
RequestMatchers is a collection of RequestMatcher's.
func NewMethodURLRequestMatchers ¶
func NewMethodURLRequestMatchers() RequestMatchers
NewMethodURLRequestMatchers creates a new default set of RequestMatcher's based on Method and URL.
func NewStrictRequestMatchers ¶
func NewStrictRequestMatchers() RequestMatchers
NewStrictRequestMatchers creates a new default sets of RequestMatcher's.
func (RequestMatchers) Add ¶
func (rm RequestMatchers) Add(reqMatchers ...RequestMatcher) RequestMatchers
Add a set of RequestMatcher's to this RequestMatchers collection.
func (RequestMatchers) Match ¶
func (rm RequestMatchers) Match(httpRequest, trackRequest *track.Request) bool
Match returns true if all RequestMatcher's in RequestMatchers return true, thereby indicating that the trackRequest matches the httpRequest. When no matchers are supplied, Match returns false.
type Setting ¶
type Setting func(vcrSettings *VCRSettings)
Setting defines an optional functional parameter as received by NewVCR().
func WithClient ¶
WithClient is an optional functional parameter to provide a VCR with a custom HTTP client.
func WithLiveOnlyMode ¶
func WithLiveOnlyMode() Setting
WithLiveOnlyMode sets the VCR to make live calls only, do not replay from cassette even if a track would exist. Perhaps more useful when used in combination with 'readOnly' to by-pass govcr entirely.
func WithOfflineMode ¶
func WithOfflineMode() Setting
WithOfflineMode sets the VCR to replay tracks from cassette, if present, but do not make live calls. govcr will return a transport error if no track was found.
func WithReadOnlyMode ¶
func WithReadOnlyMode() Setting
WithReadOnlyMode sets the VCR to replay tracks from cassette, if present, or make live calls but do not records new tracks.
func WithRequestMatchers ¶
func WithRequestMatchers(reqMatchers ...RequestMatcher) Setting
WithRequestMatchers is an optional functional parameter to provide a VCR with a set of RequestMatcher's applied when matching an HTTP/S request to an existing track on a cassette.
func WithTrackRecordingMutators ¶
WithTrackRecordingMutators is an optional functional parameter to provide a VCR with a set of track mutators applied when recording a track to a cassette.
func WithTrackReplayingMutators ¶
WithTrackReplayingMutators is an optional functional parameter to provide a VCR with a set of track mutators applied when replaying a track to a cassette. Replaying happens AFTER the request has been matched. As such, while the track's Request could be mutated, it will have no effect. However, the Request data can be referenced as part of mutating the Response.
type VCRSettings ¶
type VCRSettings struct {
// contains filtered or unexported fields
}
VCRSettings holds a set of options for the VCR.