...

Package matcher

import "google.golang.org/grpc/internal/xds/matcher"
Overview
Index

Overview ▾

Package matcher contains types that need to be shared between code under google.golang.org/grpc/xds/... and the rest of gRPC.

Index ▾

type HeaderContainsMatcher
    func NewHeaderContainsMatcher(key string, contains string, invert bool) *HeaderContainsMatcher
    func (hcm *HeaderContainsMatcher) Match(md metadata.MD) bool
    func (hcm *HeaderContainsMatcher) String() string
type HeaderExactMatcher
    func NewHeaderExactMatcher(key, exact string, invert bool) *HeaderExactMatcher
    func (hem *HeaderExactMatcher) Match(md metadata.MD) bool
    func (hem *HeaderExactMatcher) String() string
type HeaderMatcher
type HeaderPrefixMatcher
    func NewHeaderPrefixMatcher(key string, prefix string, invert bool) *HeaderPrefixMatcher
    func (hpm *HeaderPrefixMatcher) Match(md metadata.MD) bool
    func (hpm *HeaderPrefixMatcher) String() string
type HeaderPresentMatcher
    func NewHeaderPresentMatcher(key string, present bool, invert bool) *HeaderPresentMatcher
    func (hpm *HeaderPresentMatcher) Match(md metadata.MD) bool
    func (hpm *HeaderPresentMatcher) String() string
type HeaderRangeMatcher
    func NewHeaderRangeMatcher(key string, start, end int64, invert bool) *HeaderRangeMatcher
    func (hrm *HeaderRangeMatcher) Match(md metadata.MD) bool
    func (hrm *HeaderRangeMatcher) String() string
type HeaderRegexMatcher
    func NewHeaderRegexMatcher(key string, re *regexp.Regexp, invert bool) *HeaderRegexMatcher
    func (hrm *HeaderRegexMatcher) Match(md metadata.MD) bool
    func (hrm *HeaderRegexMatcher) String() string
type HeaderStringMatcher
    func NewHeaderStringMatcher(key string, sm StringMatcher, invert bool) *HeaderStringMatcher
    func (hsm *HeaderStringMatcher) Match(md metadata.MD) bool
    func (hsm *HeaderStringMatcher) String() string
type HeaderSuffixMatcher
    func NewHeaderSuffixMatcher(key string, suffix string, invert bool) *HeaderSuffixMatcher
    func (hsm *HeaderSuffixMatcher) Match(md metadata.MD) bool
    func (hsm *HeaderSuffixMatcher) String() string
type StringMatcher
    func StringMatcherForTesting(exact, prefix, suffix, contains *string, regex *regexp.Regexp, ignoreCase bool) StringMatcher
    func StringMatcherFromProto(matcherProto *v3matcherpb.StringMatcher) (StringMatcher, error)
    func (sm StringMatcher) Equal(other StringMatcher) bool
    func (sm StringMatcher) ExactMatch() string
    func (sm StringMatcher) Match(input string) bool

Package files

matcher_header.go string_matcher.go

type HeaderContainsMatcher

HeaderContainsMatcher matches on whether the header value contains the value passed into this struct.

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

func NewHeaderContainsMatcher

func NewHeaderContainsMatcher(key string, contains string, invert bool) *HeaderContainsMatcher

NewHeaderContainsMatcher returns a new HeaderContainsMatcher. key is the HTTP Header key to match on, and contains is the value that the header should should contain for a successful match. An empty contains string does not work, use HeaderPresentMatcher in that case.

func (*HeaderContainsMatcher) Match

func (hcm *HeaderContainsMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderContainsMatcher.

func (*HeaderContainsMatcher) String

func (hcm *HeaderContainsMatcher) String() string

type HeaderExactMatcher

HeaderExactMatcher matches on an exact match of the value of the header.

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

func NewHeaderExactMatcher

func NewHeaderExactMatcher(key, exact string, invert bool) *HeaderExactMatcher

NewHeaderExactMatcher returns a new HeaderExactMatcher.

func (*HeaderExactMatcher) Match

func (hem *HeaderExactMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderExactMatcher.

func (*HeaderExactMatcher) String

func (hem *HeaderExactMatcher) String() string

type HeaderMatcher

HeaderMatcher is an interface for header matchers. These are documented in (EnvoyProxy link here?). These matchers will match on different aspects of HTTP header name/value pairs.

type HeaderMatcher interface {
    Match(metadata.MD) bool
    String() string
}

type HeaderPrefixMatcher

HeaderPrefixMatcher matches on whether the prefix of the header value matches the prefix passed into this struct.

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

func NewHeaderPrefixMatcher

func NewHeaderPrefixMatcher(key string, prefix string, invert bool) *HeaderPrefixMatcher

NewHeaderPrefixMatcher returns a new HeaderPrefixMatcher.

func (*HeaderPrefixMatcher) Match

func (hpm *HeaderPrefixMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderPrefixMatcher.

func (*HeaderPrefixMatcher) String

func (hpm *HeaderPrefixMatcher) String() string

type HeaderPresentMatcher

HeaderPresentMatcher will match based on whether the header is present in the whole request.

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

func NewHeaderPresentMatcher

func NewHeaderPresentMatcher(key string, present bool, invert bool) *HeaderPresentMatcher

NewHeaderPresentMatcher returns a new HeaderPresentMatcher.

func (*HeaderPresentMatcher) Match

func (hpm *HeaderPresentMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderPresentMatcher.

func (*HeaderPresentMatcher) String

func (hpm *HeaderPresentMatcher) String() string

type HeaderRangeMatcher

HeaderRangeMatcher matches on whether the request header value is within the range. The header value must be an integer in base 10 notation.

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

func NewHeaderRangeMatcher

func NewHeaderRangeMatcher(key string, start, end int64, invert bool) *HeaderRangeMatcher

NewHeaderRangeMatcher returns a new HeaderRangeMatcher.

func (*HeaderRangeMatcher) Match

func (hrm *HeaderRangeMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderRangeMatcher.

func (*HeaderRangeMatcher) String

func (hrm *HeaderRangeMatcher) String() string

type HeaderRegexMatcher

HeaderRegexMatcher matches on whether the entire request header value matches the regex.

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

func NewHeaderRegexMatcher

func NewHeaderRegexMatcher(key string, re *regexp.Regexp, invert bool) *HeaderRegexMatcher

NewHeaderRegexMatcher returns a new HeaderRegexMatcher.

func (*HeaderRegexMatcher) Match

func (hrm *HeaderRegexMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderRegexMatcher.

func (*HeaderRegexMatcher) String

func (hrm *HeaderRegexMatcher) String() string

type HeaderStringMatcher

HeaderStringMatcher matches on whether the header value matches against the StringMatcher specified.

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

func NewHeaderStringMatcher

func NewHeaderStringMatcher(key string, sm StringMatcher, invert bool) *HeaderStringMatcher

NewHeaderStringMatcher returns a new HeaderStringMatcher.

func (*HeaderStringMatcher) Match

func (hsm *HeaderStringMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the specified StringMatcher.

func (*HeaderStringMatcher) String

func (hsm *HeaderStringMatcher) String() string

type HeaderSuffixMatcher

HeaderSuffixMatcher matches on whether the suffix of the header value matches the suffix passed into this struct.

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

func NewHeaderSuffixMatcher

func NewHeaderSuffixMatcher(key string, suffix string, invert bool) *HeaderSuffixMatcher

NewHeaderSuffixMatcher returns a new HeaderSuffixMatcher.

func (*HeaderSuffixMatcher) Match

func (hsm *HeaderSuffixMatcher) Match(md metadata.MD) bool

Match returns whether the passed in HTTP Headers match according to the HeaderSuffixMatcher.

func (*HeaderSuffixMatcher) String

func (hsm *HeaderSuffixMatcher) String() string

type StringMatcher

StringMatcher contains match criteria for matching a string, and is an internal representation of the `StringMatcher` proto defined at https://github.com/envoyproxy/envoy/blob/main/api/envoy/type/matcher/v3/string.proto.

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

func StringMatcherForTesting

func StringMatcherForTesting(exact, prefix, suffix, contains *string, regex *regexp.Regexp, ignoreCase bool) StringMatcher

StringMatcherForTesting is a helper function to create a StringMatcher based on the given arguments. Intended only for testing purposes.

func StringMatcherFromProto

func StringMatcherFromProto(matcherProto *v3matcherpb.StringMatcher) (StringMatcher, error)

StringMatcherFromProto is a helper function to create a StringMatcher from the corresponding StringMatcher proto.

Returns a non-nil error if matcherProto is invalid.

func (StringMatcher) Equal

func (sm StringMatcher) Equal(other StringMatcher) bool

Equal returns true if other and sm are equivalent to each other.

func (StringMatcher) ExactMatch

func (sm StringMatcher) ExactMatch() string

ExactMatch returns the value of the configured exact match or an empty string if exact match criteria was not specified.

func (StringMatcher) Match

func (sm StringMatcher) Match(input string) bool

Match returns true if input matches the criteria in the given StringMatcher.