fixture

package
v0.207.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultProcessRequest

func DefaultProcessRequest(req *http.Request) *http.Request

DefaultProcessRequest is a default implementation of ProcessRequest. It removes the Date, Cookie, Authorization, and User-Agent headers.

func DefaultProcessResponse

func DefaultProcessResponse(res *http.Response) *http.Response

DefaultProcessResponse is a default implementation of ProcessResponse. It removes the Set-Cookie header from the response.

Types

type Fixture

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

func NewFixture

func NewFixture(store storage.Storage) *Fixture

NewFixture creates a new Fixture.

func (*Fixture) Add

func (f *Fixture) Add(originalReq *http.Request, originalRes *http.Response) error

Add processes the http.Request and http.Response with the Fixture's RequestProcessor and ResponseProcessor and adds them to the Fixure's Storage.

func (*Fixture) Delete

func (f *Fixture) Delete(req *http.Request) bool

Delete deletes the entry with the given ID from the Fixture's Storage.

func (*Fixture) Entries

func (f *Fixture) Entries() []*storage.Entry

Entries returns the entries from the Fixture's Storage.

func (*Fixture) Match

func (f *Fixture) Match(originalReq *http.Request) *http.Response

Match compares incoming request to entries from the Fixture's Storage.

func (*Fixture) WithMatcher

func (f *Fixture) WithMatcher(matcher Matcher)

WithMatcher sets the Matcher for the Fixture. Note: Overriding the fixture's matcher will not affect the host matching behavior that can be configured in proxy.json.

func (*Fixture) WithRequestProcessor

func (f *Fixture) WithRequestProcessor(processRequest RequestProcessor)

WithRequestProcessor sets the RequestProcessor for the Fixture.

func (*Fixture) WithResponseProcessor

func (f *Fixture) WithResponseProcessor(processResponse ResponseProcessor)

WithResponseProcessor sets the ResponseProcessor for the Fixture.

type Matcher

type Matcher func(b *http.Request) *http.Response

type RequestProcessor

type RequestProcessor func(req *http.Request) *http.Request

type ResponseProcessor

type ResponseProcessor func(res *http.Response) *http.Response

Jump to

Keyboard shortcuts

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