func (f *Filter) ModifyRequest(req *http.Request) error {
	if f.reqcond == nil {
		return fmt.Errorf("filter.ModifyRequest: no request condition set. Set condition with SetRequestCondition")
	}
	match := f.reqcond.MatchRequest(req)
	if match {
		log.Debugf("filter.ModifyRequest: matched %s", req.URL)
		return f.treqmod.ModifyRequest(req)
	}
	return f.freqmod.ModifyRequest(req)
}
ModifyRequest evaluates reqcond and executes treqmod iff reqcond evaluates
to true; otherwise, freqmod is executed.
package filter
import (
	"fmt"
	"net/http"
	"github.com/google/martian/v3"
	"github.com/google/martian/v3/log"
	"github.com/google/martian/v3/verify"
)
var noop = martian.Noop("Filter")
type Filter struct {
	reqcond RequestCondition
	rescond ResponseCondition
	treqmod martian.RequestModifier
	tresmod martian.ResponseModifier
	freqmod martian.RequestModifier
	fresmod martian.ResponseModifier
}
func New() *Filter {
	return &Filter{
		treqmod: noop,
		tresmod: noop,
		fresmod: noop,
		freqmod: noop,
	}
}
func (f *Filter) SetRequestCondition(reqcond RequestCondition) {
	f.reqcond = reqcond
}
func (f *Filter) SetResponseCondition(rescond ResponseCondition) {
	f.rescond = rescond
}
func (f *Filter) SetRequestModifier(reqmod martian.RequestModifier) {
	f.RequestWhenTrue(reqmod)
}
func (f *Filter) RequestWhenTrue(mod martian.RequestModifier) {
	if mod == nil {
		f.treqmod = noop
		return
	}
	f.treqmod = mod
}
func (f *Filter) SetResponseModifier(resmod martian.ResponseModifier) {
	f.ResponseWhenTrue(resmod)
}
func (f *Filter) RequestWhenFalse(mod martian.RequestModifier) {
	if mod == nil {
		f.freqmod = noop
		return
	}
	f.freqmod = mod
}
func (f *Filter) ResponseWhenTrue(mod martian.ResponseModifier) {
	if mod == nil {
		f.tresmod = noop
		return
	}
	f.tresmod = mod
}
func (f *Filter) ResponseWhenFalse(mod martian.ResponseModifier) {
	if mod == nil {
		f.fresmod = noop
		return
	}
	f.fresmod = mod
}