recorder

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package recorder allows to capture request/response pairs via a reverse proxy and generate tests for these pairs.

Index

Constants

This section is empty.

Variables

View Source
var Events []Event

Events is the global list of recorded events.

Functions

func DumpEvents

func DumpEvents(events []Event, directory string, suitename string) error

DumpEvents writes events to directory, it extracts common request headers.

func ExtractCommonRequestHeaders

func ExtractCommonRequestHeaders(events []Event) http.Header

func ExtractCommonResponseHeaders

func ExtractCommonResponseHeaders(events []Event) http.Header

func StartReverseProxy

func StartReverseProxy(port string, remote *url.URL, opts Options) error

StartReverseProxy listens on the local port and forwards request to remote while capturing the request/response pairs selected by opts.

Types

type Event

type Event struct {
	Request      *http.Request              // The request.
	Response     *httptest.ResponseRecorder // The recorded response.
	RequestBody  string                     // The captured body.
	ResponseBody string
	Timestamp    time.Time // Timestamp when caputred.
	Name         string    // Used during dumping.
}

Event is a request/response pair.

type Options

type Options struct {
	// Disarm is the time span after a captured request/response pair
	// in which the capturing is disarmed.
	Disarm time.Duration

	// IgnoredContentType allows to skip capturing a request whose
	// Content-Type header matches.
	IgnoredContentType *regexp.Regexp

	// IgnoredPath allows to skip capturing events based on the
	// requested path,
	IgnoredPath *regexp.Regexp
}

Options determining which and how events should be captured.

type Suite

type Suite struct {
	Name        string
	Description string `json:",omitempty"`
	Tests       []string
	Variables   map[string]string
}

Suite is a reduced version of ht.Suite suitable to serialization to JSON5.

type Test

type Test struct {
	Name        string
	Description string   `json:",omitempty"`
	BasedOn     []string `json:",omitempty"`
	Request     ht.Request
	Checks      ht.CheckList `json:",omitempty"`
}

Test is a reduced version of ht.Test suitable for serialization to JSON5.

Jump to

Keyboard shortcuts

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