func (v *Verifier) ResetRequestVerifications() {
	v.err = martian.NewMultiError()
}
ResetRequestVerifications clears all failed request verifications.
package bffurl
import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"github.com/google/martian/v3"
	"github.com/google/martian/v3/log"
	"github.com/google/martian/v3/martianurl"
	"github.com/google/martian/v3/parse"
	"github.com/google/martian/v3/verify"
)
const (
	errFormat     = "request(%s) url verify failure:\n%s"
	errPartFormat = "\t%s: got %q, want %q"
)
func init() {
	parse.Register("bff.URLVerifier", verifierFromJSON)
}
type Verifier struct {
	url     *url.URL
	err     *martian.MultiError
	pattern *Pattern
}
type verifierJSON struct {
	Scheme string               `json:"scheme"`
	Host   string               `json:"host"`
	Path   string               `json:"path"`
	Query  string               `json:"query"`
	Scope  []parse.ModifierType `json:"scope"`
}
func NewVerifier(u *url.URL) verify.RequestVerifier {
	log.Debugf("bff.NewURLVerifier: %s", u)
	return &Verifier{
		url:     u,
		err:     martian.NewMultiError(),
		pattern: NewPattern(u.Path),
	}
}
func (v *Verifier) ModifyRequest(req *http.Request) error {
	ctx := martian.NewContext(req)
	if ctx.IsAPIRequest() {
		return nil
	}
	var failures []string
	u := req.URL
	if v.url.Scheme != "" && v.url.Scheme != u.Scheme {
		f := fmt.Sprintf(errPartFormat, "Scheme", u.Scheme, v.url.Scheme)
		failures = append(failures, f)
	}
	if v.url.Host != "" && !martianurl.MatchHost(u.Host, v.url.Host) {
		f := fmt.Sprintf(errPartFormat, "Host", u.Host, v.url.Host)
		failures = append(failures, f)
	}
	if v.url.Path != "" && !v.pattern.Match(req) {
		f := fmt.Sprintf(errPartFormat, "Path", u.Path, v.url.Path)
		failures = append(failures, f)
	}
	if v.url.RawQuery != "" && v.url.RawQuery != u.RawQuery {
		f := fmt.Sprintf(errPartFormat, "Query", u.RawQuery, v.url.RawQuery)
		failures = append(failures, f)
	}
	if v.url.Fragment != "" && v.url.Fragment != u.Fragment {
		f := fmt.Sprintf(errPartFormat, "Fragment", u.Fragment, v.url.Fragment)
		failures = append(failures, f)
	}
	if len(failures) > 0 {
		err := fmt.Errorf(errFormat, u, strings.Join(failures, "\n"))
		v.err.Add(err)
	}
	return nil
}
func (v *Verifier) VerifyRequests() error {
	if v.err.Empty() {
		return nil
	}
	return v.err
}