storage

package
v0.159.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Request  *http.Request
	Response *http.Response
}

Entry represents a http.Request and http.Response pair.

func (*Entry) Match added in v0.129.0

func (e *Entry) Match(incoming *http.Request) *http.Response

Match compares the given http.Request with the stored http.Request and returns the stored http.Response if a match is found.

type HAR added in v0.129.0

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

HAR is a Storage implementation that stores requests and responses in HAR format on disk.

func NewHARStorage

func NewHARStorage(path string) *HAR

NewHARStorage creates a new HARStorage.

func (*HAR) Add added in v0.129.0

func (s *HAR) Add(req *http.Request, res *http.Response) error

Add converts the http.Request and http.Response to a har.Entry and adds it to the Fixture.

func (*HAR) Delete added in v0.129.0

func (s *HAR) Delete(req *http.Request) bool

Delete removes the HAR entry matching the given Request.

func (*HAR) Entries added in v0.129.0

func (s *HAR) Entries() []*Entry

Entries converts HAR entries to a slice of Entry (http.Request and http.Response pairs).

func (*HAR) Init added in v0.129.0

func (s *HAR) Init()

Init initializes the HAR storage.

func (*HAR) Load added in v0.129.0

func (s *HAR) Load() error

Load reads the HAR from disk.

func (*HAR) Match added in v0.129.0

func (s *HAR) Match(req *http.Request) *http.Response

Match returns the stored http.Response for the given request.

func (*HAR) Save added in v0.129.0

func (s *HAR) Save() error

Save writes the HAR to disk.

func (*HAR) WithCurrentTimeOverride added in v0.129.0

func (s *HAR) WithCurrentTimeOverride(fn func() time.Time)

WithCurrentTimeOverride replaces the default s.currentTime() with the given function.

func (*HAR) WithUUIDOverride added in v0.129.0

func (s *HAR) WithUUIDOverride(fn func() string)

WithUUIDOverride replaces the default s.newUUID() with the given function.

type OpenAPI added in v0.129.0

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

OpenAPI is a storage implementation that stores requests and responses in OpenAPI format on disk.

func NewOpenAPIStorage added in v0.129.0

func NewOpenAPIStorage(path string) *OpenAPI

NewOpenAPIStorage creates a new OpenAPI storage.

func (*OpenAPI) Add added in v0.129.0

func (o *OpenAPI) Add(*http.Request, *http.Response) error

Add is a no-op for OpenAPI storage.

func (*OpenAPI) Delete added in v0.129.0

func (o *OpenAPI) Delete(*http.Request) bool

Delete is a no-op for OpenAPI storage.

func (*OpenAPI) Entries added in v0.129.0

func (o *OpenAPI) Entries() []*Entry

Entries is a no-op for OpenAPI storage.

func (*OpenAPI) Load added in v0.129.0

func (o *OpenAPI) Load() error

Load loads the OpenAPI specification from disk.

func (*OpenAPI) Match added in v0.129.0

func (o *OpenAPI) Match(req *http.Request) *http.Response

Match returns an example response for the given request.

func (*OpenAPI) Save added in v0.129.0

func (o *OpenAPI) Save() error

Save is a no-op for OpenAPI storage.

type Storage

type Storage interface {
	Add(*http.Request, *http.Response) error
	Delete(*http.Request) bool
	Entries() []*Entry
	Match(*http.Request) *http.Response
}

Storage is an interface for storing Entry objects.

Jump to

Keyboard shortcuts

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