storage

package
v0.128.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 14 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 {
	ID       string
	Request  *http.Request
	Response *http.Response
}

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

type HARStorage

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

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

func NewHARStorage

func NewHARStorage(path string) *HARStorage

NewHARStorage creates a new HARStorage.

func (*HARStorage) Add

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

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

func (*HARStorage) Delete

func (s *HARStorage) Delete(id string) bool

Delete removes the HAR entry with the given ID.

func (*HARStorage) Entries

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

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

func (*HARStorage) Init

func (s *HARStorage) Init()

func (*HARStorage) Load

func (s *HARStorage) Load() error

Load reads the HAR from disk.

func (*HARStorage) Save

func (s *HARStorage) Save() error

Save writes the HAR to disk.

func (*HARStorage) WithCurrentTimeOverride

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

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

func (*HARStorage) WithUUIDOverride

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

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

type Storage

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

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