func (f *Filter) ModifyResponse(res *http.Response) error {
	if f.rescond == nil {
		return fmt.Errorf("filter.ModifyResponse: no response condition set. Set condition with SetResponseCondition")
	}
	match := f.rescond.MatchResponse(res)
	if match {
		requ := ""
		if res.Request != nil {
			requ = res.Request.URL.String()
		}
		log.Debugf("filter.ModifyResponse: %s", requ)
		return f.tresmod.ModifyResponse(res)
	}
	return f.fresmod.ModifyResponse(res)
}
ModifyResponse evaluates rescond and executes tresmod iff rescond evaluates
to true; otherwise, fresmod 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
}
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)
}