replay

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package replay provides the ability to record and replay HTTP requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGCPDialOptions

func NewGCPDialOptions(t *testing.T, mode recorder.Mode, filename string) (opts []grpc.DialOption, done func())

NewGCPDialOptions return grpc.DialOptions that are to be appended to a GRPC dial request. These options allow a recorder/replayer to intercept RPCs and save RPCs to the file at filename, or read the RPCs from the file and return them.

func NewRecorder

func NewRecorder(t *testing.T, mode recorder.Mode, matcher *ProviderMatcher, filename string) (r *recorder.Recorder, done func(), err error)

NewRecorder returns a go-vcr.Recorder which reads or writes golden files from the given path. When recording, done() saves the recording to a golden file. The Authorization request header is dropped, but otherwise the raw HTTP requests/responses are saved When replaying, HTTP requests are expected to arrive in the same order as in the recording. They are verified to have the same: -- Method -- URL -- Specific HTTP headers ((optional, via matcher). -- Body (optionally scrubbed, via matcher).

Types

type ProviderMatcher

type ProviderMatcher struct {
	// Headers is a slice of HTTP request headers that will be verified to match.
	Headers []string
	// DropRequestHeaders causes all HTTP request headers that match the given
	// regular expression to be dropped from the recording.
	// There should be no overlap with Headers.
	// In addition, the "Authorization" header is always dropped.
	DropRequestHeaders *regexp.Regexp
	// DropResponseHeaders causes all HTTP response headers that match the given
	// regular expression to be dropped from the recording.
	// In addition, the "Duration" header is always dropped.
	DropResponseHeaders *regexp.Regexp
	// URLScrubbers is a slice of regular expressions that will be used to
	// scrub the URL before matching, via ReplaceAllString.
	URLScrubbers []*regexp.Regexp
	// BodyScrubber is a slice of regular expressions that will be used to
	// scrub the HTTP request body before matching, via ReplaceAllString.
	BodyScrubbers []*regexp.Regexp
}

ProviderMatcher allows providers to customize how HTTP requests are matched and recorded.

Jump to

Keyboard shortcuts

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