httpreplay

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package httpreplay provides an API for recording and replaying traffic from HTTP-based Google API clients.

To record:

  1. Call NewRecorder to get a Recorder.
  2. Use its Client method to obtain an HTTP client to use when making API calls.
  3. Close the Recorder when you're done. That will save the log of interactions to the file you provided to NewRecorder.

To replay:

  1. Call NewReplayer with the same filename you used to record to get a Replayer.
  2. Call its Client method and use the client to make the same API calls. You will get back the recorded responses.
  3. Close the Replayer when you're done.

This package is EXPERIMENTAL and is subject to change or removal without notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

A Recorder records HTTP interactions.

func NewRecorder

func NewRecorder(filename string) (*Recorder, error)

NewRecorder creates a recorder that writes to filename.

You must call Close on the Recorder to ensure that all data is written.

func (*Recorder) Client

func (r *Recorder) Client(ctx context.Context, opts ...option.ClientOption) (*http.Client, error)

Client returns an http.Client to be used for recording. Provide authentication options like option.WithTokenSource as you normally would, or omit them to use Application Default Credentials.

func (*Recorder) Close

func (r *Recorder) Close() error

Close closes the Recorder and saves the log file.

type Replayer

type Replayer struct {
	// contains filtered or unexported fields
}

A Replayer replays previously recorded HTTP interactions.

func NewReplayer

func NewReplayer(filename string) (*Replayer, error)

NewReplayer creates a replayer that reads from filename.

func (*Replayer) Client

func (r *Replayer) Client(ctx context.Context) (*http.Client, error)

Client returns an HTTP client for replaying. The client does not need to be configured with credentials for authenticating to a server, since it never contacts a real backend.

func (*Replayer) Close

func (r *Replayer) Close() error

Close closes the replayer.

Directories

Path Synopsis
cmd
internal
proxy
The proxy package provides a record/replay HTTP proxy.
The proxy package provides a record/replay HTTP proxy.

Jump to

Keyboard shortcuts

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