Documentation
¶
Index ¶
Constants ¶
const ( Auto string = "auto" Record string = "record" Replay string = "replay" )
These constants define the different playback modes Auto mode: If a cassette exists, replays from the cassette or else records a new cassette.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cassette ¶ added in v1.5.5
type Cassette []interaction
Cassette is used to store a sequence of interactions that happened part of a single action
type Recorder ¶ added in v1.5.5
type Recorder struct {
// contains filtered or unexported fields
}
An Recorder proxies requests to a remote host and records all interactions.
type Replayer ¶ added in v1.5.5
type Replayer struct {
// contains filtered or unexported fields
}
An Replayer receives incoming requests and returns recorded responses from the provided cassette.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server implements the full functionality of `stripe playback` as a HTTP server. Acting as a proxy server for the Stripe API, it can both record and replay interactions using cassette files.
func NewServer ¶
func NewServer(remoteURL string, webhookURL string, absCassetteDirectory string, mode string, initialCassetteFilepath string) (server *Server, err error)
NewServer instantiates a Server struct, representing the configuration and current state of a playback proxy server The cassetteDirectory param must be an absolute path initialCasssetteFilepath can be a relative path (interpreted relative to cassetteDirectory) or an absolute path
func (*Server) InitializeServer ¶
InitializeServer sets up and returns a http.Server that acts as a playback proxy
func (*Server) OnSwitchMode ¶ added in v1.5.4
OnSwitchMode listens to the switchModeChan and calls f when it receives a mode string
type YAMLCassette ¶ added in v1.5.5
type YAMLCassette []YAMLInteraction
YAMLCassette is a playback.cassette interface encoded to YAML
type YAMLInteraction ¶ added in v1.5.5
type YAMLInteraction struct {
Type interactionType
Request YAMLRequest
Response YAMLResponse
}
YAMLInteraction is a playback.interaction interface encoded to YAML
type YAMLRequest ¶ added in v1.5.5
type YAMLRequest struct {
Method string `yaml:"method"`
Body string `yaml:"body"`
Headers http.Header `yaml:"headers"`
URL url.URL `yaml:"url"`
}
YAMLRequest is a playback.httpRequest interface encoded to YAML
type YAMLResponse ¶ added in v1.5.5
type YAMLResponse struct {
Headers http.Header `yaml:"headers"`
Body string `yaml:"body"`
StatusCode int `yaml:"status_code"`
}
YAMLResponse is a playback.httpResponse interface encoded to YAML
type YAMLSerializer ¶ added in v1.5.5
type YAMLSerializer struct{}
YAMLSerializer encodes/persists cassettes to files and decodes yaml cassette files.
func (YAMLSerializer) DecodeCassette ¶ added in v1.5.5
func (s YAMLSerializer) DecodeCassette(data []byte) (Cassette, error)
DecodeCassette takes in a []byte of YAML and returns a playback.cassette of it
func (YAMLSerializer) EncodeCassette ¶ added in v1.5.5
func (s YAMLSerializer) EncodeCassette(cassette Cassette) ([]byte, error)
EncodeCassette takes in a playback.cassette and returns an []byte of the YAML-encoded cassette