Skip to content

Commit

Permalink
xds: rename helper to remove mention of OutgoingCtx (grpc#7854)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Nov 18, 2024
1 parent fdc28bf commit d7f27c4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/xds/matcher/matcher_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type HeaderMatcher interface {
String() string
}

// mdValuesFromOutgoingCtx retrieves metadata from context. If there are
// valueFromMD retrieves metadata from context. If there are
// multiple values, the values are concatenated with "," (comma and no space).
//
// All header matchers only match against the comma-concatenated string.
func mdValuesFromOutgoingCtx(md metadata.MD, key string) (string, bool) {
func valueFromMD(md metadata.MD, key string) (string, bool) {
vs, ok := md[key]
if !ok {
return "", false
Expand All @@ -63,7 +63,7 @@ func NewHeaderExactMatcher(key, exact string, invert bool) *HeaderExactMatcher {
// Match returns whether the passed in HTTP Headers match according to the
// HeaderExactMatcher.
func (hem *HeaderExactMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hem.key)
v, ok := valueFromMD(md, hem.key)
if !ok {
return false
}
Expand All @@ -90,7 +90,7 @@ func NewHeaderRegexMatcher(key string, re *regexp.Regexp, invert bool) *HeaderRe
// Match returns whether the passed in HTTP Headers match according to the
// HeaderRegexMatcher.
func (hrm *HeaderRegexMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hrm.key)
v, ok := valueFromMD(md, hrm.key)
if !ok {
return false
}
Expand All @@ -117,7 +117,7 @@ func NewHeaderRangeMatcher(key string, start, end int64, invert bool) *HeaderRan
// Match returns whether the passed in HTTP Headers match according to the
// HeaderRangeMatcher.
func (hrm *HeaderRangeMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hrm.key)
v, ok := valueFromMD(md, hrm.key)
if !ok {
return false
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func NewHeaderPresentMatcher(key string, present bool, invert bool) *HeaderPrese
// Match returns whether the passed in HTTP Headers match according to the
// HeaderPresentMatcher.
func (hpm *HeaderPresentMatcher) Match(md metadata.MD) bool {
vs, ok := mdValuesFromOutgoingCtx(md, hpm.key)
vs, ok := valueFromMD(md, hpm.key)
present := ok && len(vs) > 0 // TODO: Are we sure we need this len(vs) > 0?
return present == hpm.present
}
Expand All @@ -174,7 +174,7 @@ func NewHeaderPrefixMatcher(key string, prefix string, invert bool) *HeaderPrefi
// Match returns whether the passed in HTTP Headers match according to the
// HeaderPrefixMatcher.
func (hpm *HeaderPrefixMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hpm.key)
v, ok := valueFromMD(md, hpm.key)
if !ok {
return false
}
Expand All @@ -201,7 +201,7 @@ func NewHeaderSuffixMatcher(key string, suffix string, invert bool) *HeaderSuffi
// Match returns whether the passed in HTTP Headers match according to the
// HeaderSuffixMatcher.
func (hsm *HeaderSuffixMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hsm.key)
v, ok := valueFromMD(md, hsm.key)
if !ok {
return false
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func NewHeaderContainsMatcher(key string, contains string, invert bool) *HeaderC
// Match returns whether the passed in HTTP Headers match according to the
// HeaderContainsMatcher.
func (hcm *HeaderContainsMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hcm.key)
v, ok := valueFromMD(md, hcm.key)
if !ok {
return false
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func NewHeaderStringMatcher(key string, sm StringMatcher, invert bool) *HeaderSt
// Match returns whether the passed in HTTP Headers match according to the
// specified StringMatcher.
func (hsm *HeaderStringMatcher) Match(md metadata.MD) bool {
v, ok := mdValuesFromOutgoingCtx(md, hsm.key)
v, ok := valueFromMD(md, hsm.key)
if !ok {
return false
}
Expand Down

0 comments on commit d7f27c4

Please sign in to comment.