Documentation ¶
Overview ¶
Package recorder allows to capture request/response pairs via a reverse proxy and generate tests for these pairs.
Index ¶
- Constants
- Variables
- func DumpEvents(events []Event, directory string, suitename string) error
- func ExtractCommonRequestHeaders(events []Event) http.Header
- func ExtractCommonResponseHeaders(events []Event) http.Header
- func StartReverseProxy(port string, remoteURL *url.URL, opts Options) error
- type Event
- type Options
- type Rewriter
- type Suite
- type Test
Constants ¶
View Source
const ( // Different things to rewrite. RewriteNothing uint32 = 0 RewriteResponseHeader uint32 = 1 << (iota - 1) RewriteResponseBody RewriteRequestHeader RewriteRequestBody )
Variables ¶
View Source
var Events []Event
Events is the global list of recorded events.
Functions ¶
func DumpEvents ¶
DumpEvents writes events to directory, it extracts common request headers.
func ExtractCommonRequestHeaders ¶
ExtractCommonRequestHeaders from events.
func ExtractCommonResponseHeaders ¶
ExtractCommonResponseHeaders from events.
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 // Rewrite determines what is rewritten. Rewrite Rewriter }
Options determining which and how events should be captured.
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
Rewriter from remote to local host.
func NewRewriter ¶
NewRewriter for what between local and remote.
Click to show internal directories.
Click to hide internal directories.