Exemplo n.º 1
0
// NewVerifier creates a new header verifier for the given name and value.
func NewVerifier(name, value string) verify.RequestResponseVerifier {
	return &verifier{
		name:   name,
		value:  value,
		reqerr: verify.NewMultiError(),
		reserr: verify.NewMultiError(),
	}
}
Exemplo n.º 2
0
// NewVerifier returns a new method verifier.
func NewVerifier(method string) (verify.RequestVerifier, error) {
	if method == "" {
		return nil, fmt.Errorf("%s is not a valid HTTP method", method)
	}
	return &verifier{
		method: method,
		err:    verify.NewMultiError(),
	}, nil
}
Exemplo n.º 3
0
// NewVerifier returns a new param verifier.
func NewVerifier(key, value string) (verify.RequestVerifier, error) {
	if key == "" {
		return nil, fmt.Errorf("no key provided to param verifier")
	}
	return &verifier{
		key:   key,
		value: value,
		err:   verify.NewMultiError(),
	}, nil
}
Exemplo n.º 4
0
// VerifyRequests returns a MultiError containing all the
// verification errors returned by request verifiers.
func (g *Group) VerifyRequests() error {
	g.reqmu.Lock()
	defer g.reqmu.Unlock()

	merr := verify.NewMultiError()
	for _, reqmod := range g.reqmods {
		reqv, ok := reqmod.(verify.RequestVerifier)
		if !ok {
			continue
		}

		if err := reqv.VerifyRequests(); err != nil {
			merr.Add(err)
		}
	}

	if merr.Empty() {
		return nil
	}

	return merr
}
Exemplo n.º 5
0
// NewVerifier returns a new URL verifier.
func NewVerifier(url *url.URL) verify.RequestVerifier {
	return &Verifier{
		url: url,
		err: verify.NewMultiError(),
	}
}
Exemplo n.º 6
0
// ResetRequestVerifications clears all failed request verifications.
func (v *Verifier) ResetRequestVerifications() {
	v.err = verify.NewMultiError()
}
Exemplo n.º 7
0
// ResetResponseVerifications clears all failed response verifications.
func (v *verifier) ResetResponseVerifications() {
	v.reserr = verify.NewMultiError()
}
Exemplo n.º 8
0
// NewVerifier returns a new status.Verifier for statusCode.
func NewVerifier(statusCode int) verify.ResponseVerifier {
	return &Verifier{
		statusCode: statusCode,
		err:        verify.NewMultiError(),
	}
}