storage

package
v0.188.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

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

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

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

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

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

Delete removes the HAR entry matching the given Request.

func (*HAR) Entries

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

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

func (*HAR) Init

func (s *HAR) Init()

Init initializes the HAR storage.

func (*HAR) Load

func (s *HAR) Load() error

Load reads the HAR from disk.

func (*HAR) Match

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

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

func (*HAR) Save

func (s *HAR) Save() error

Save writes the HAR to disk.

func (*HAR) WithCurrentTimeOverride

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

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

func (*HAR) WithUUIDOverride

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

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

type OpenAPI

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

func NewOpenAPIStorage(path string) *OpenAPI

NewOpenAPIStorage creates a new OpenAPI storage.

func (*OpenAPI) Add

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

Add is a no-op for OpenAPI storage.

func (*OpenAPI) Delete

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

Delete is a no-op for OpenAPI storage.

func (*OpenAPI) Entries

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

Entries is a no-op for OpenAPI storage.

func (*OpenAPI) Load

func (o *OpenAPI) Load() error

Load loads the OpenAPI specification from disk.

func (*OpenAPI) Match

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

Match returns an example response for the given request.

func (*OpenAPI) Save

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