aurestrecorder

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RecorderPathEnvVariable = "GO_AUTUMN_RESTCLIENT_RECORDER_PATH"

Variables

This section is empty.

Functions

func ConstructFilename

func ConstructFilename(method string, requestUrl string) (string, error)

func ConstructFilenameV2 added in v0.4.1

func ConstructFilenameV2(method string, requestUrl string) (string, error)

func ConstructFilenameV2WithBody added in v0.6.0

func ConstructFilenameV2WithBody(method string, requestUrl string, _ interface{}) (string, error)

func ConstructFilenameV3 added in v0.4.3

func ConstructFilenameV3(method string, requestUrl string) (string, error)

func ConstructFilenameV3WithBody added in v0.6.0

func ConstructFilenameV3WithBody(method string, requestUrl string, _ interface{}) (string, error)

func ConstructFilenameWithBody added in v0.6.0

func ConstructFilenameWithBody(method string, requestUrl string, _ interface{}) (string, error)

func New

func New(wrapped aurestclientapi.Client, additionalOptions ...RecorderOptions) aurestclientapi.Client

New builds a new http recorder.

Insert this into your stack just above the actual http client.

Normally it does nothing, but if you set the environment variable RecorderPathEnvVariable to a path to a directory, it will write response recordings for your requests that you can then play back using aurestplayback.PlaybackImpl in your tests.

You can optionally add a RecorderOptions instance to your call. The ... is really just so it's an optional argument.

Types

type ConstructFilenameFunction added in v0.6.0

type ConstructFilenameFunction func(method string, requestUrl string, requestBody interface{}) (string, error)

type RecorderData

type RecorderData struct {
	Method         string                         `json:"method"`
	RequestUrl     string                         `json:"requestUrl"`
	RequestBody    interface{}                    `json:"requestBody,omitempty"`
	ParsedResponse aurestclientapi.ParsedResponse `json:"parsedResponse"`
	Error          error                          `json:"error,omitempty"`
}

type RecorderImpl

type RecorderImpl struct {
	Wrapped               aurestclientapi.Client
	RecorderPath          string
	ConstructFilenameFunc ConstructFilenameFunction
}

func (*RecorderImpl) Perform

func (c *RecorderImpl) Perform(ctx context.Context, method string, requestUrl string, requestBody interface{}, response *aurestclientapi.ParsedResponse) error

type RecorderOptions added in v0.6.0

type RecorderOptions struct {
	ConstructFilenameFunc ConstructFilenameFunction
}

Jump to

Keyboard shortcuts

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