filter

package
v3.3.6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filter provides a modifier that executes a given set of child modifiers based on the evaluated value of the provided conditional.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

Filter is a modifer that contains conditions to evaluate on request and response as well as a set of modifiers to execute based on the value of the provided RequestCondition or ResponseCondition.

func New

func New() *Filter

New returns a pointer to a Filter with all child modifiers initialized to the noop modifier.

func (*Filter) ModifyRequest

func (f *Filter) ModifyRequest(req *http.Request) error

ModifyRequest evaluates reqcond and executes treqmod iff reqcond evaluates to true; otherwise, freqmod is executed.

func (*Filter) ModifyResponse

func (f *Filter) ModifyResponse(res *http.Response) error

ModifyResponse evaluates rescond and executes tresmod iff rescond evaluates to true; otherwise, fresmod is executed.

func (*Filter) RequestWhenFalse

func (f *Filter) RequestWhenFalse(mod martian.RequestModifier)

RequestWhenFalse sets the martian.RequestModifier that is executed when the RequestCondition evaluates to False.

func (*Filter) RequestWhenTrue

func (f *Filter) RequestWhenTrue(mod martian.RequestModifier)

RequestWhenTrue sets the martian.RequestModifier that is executed when the RequestCondition evaluates to True.

func (*Filter) ResetRequestVerifications

func (f *Filter) ResetRequestVerifications()

ResetRequestVerifications resets the state of the contained request verifiers.

func (*Filter) ResetResponseVerifications

func (f *Filter) ResetResponseVerifications()

ResetResponseVerifications resets the state of the contained request verifiers.

func (*Filter) ResponseWhenFalse

func (f *Filter) ResponseWhenFalse(mod martian.ResponseModifier)

ResponseWhenFalse sets the martian.ResponseModifier that is executed when the ResponseCondition evaluates to False.

func (*Filter) ResponseWhenTrue

func (f *Filter) ResponseWhenTrue(mod martian.ResponseModifier)

ResponseWhenTrue sets the martian.ResponseModifier that is executed when the ResponseCondition evaluates to True.

func (*Filter) SetRequestCondition

func (f *Filter) SetRequestCondition(reqcond RequestCondition)

SetRequestCondition sets the condition to evaluate on requests.

func (*Filter) SetRequestModifier

func (f *Filter) SetRequestModifier(reqmod martian.RequestModifier)

SetRequestModifier sets the martian.RequestModifier that is executed when the RequestCondition evaluates to True. This function is provided to maintain backwards compatability with filtering prior to filter.Filter.

func (*Filter) SetResponseCondition

func (f *Filter) SetResponseCondition(rescond ResponseCondition)

SetResponseCondition sets the condition to evaluate on responses.

func (*Filter) SetResponseModifier

func (f *Filter) SetResponseModifier(resmod martian.ResponseModifier)

SetResponseModifier sets the martian.ResponseModifier that is executed when the ResponseCondition evaluates to True. This function is provided to maintain backwards compatability with filtering prior to filter.Filter.

func (*Filter) VerifyRequests

func (f *Filter) VerifyRequests() error

VerifyRequests returns an error containing all the verification errors returned by request verifiers.

func (*Filter) VerifyResponses

func (f *Filter) VerifyResponses() error

VerifyResponses returns an error containing all the verification errors returned by response verifiers.

type RequestCondition

type RequestCondition interface {
	MatchRequest(*http.Request) bool
}

RequestCondition is the interface that describes matchers for response filters

type ResponseCondition

type ResponseCondition interface {
	MatchResponse(*http.Response) bool
}

ResponseCondition is the interface that describes matchers for response filters

Jump to

Keyboard shortcuts

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