Match returns true if all matchers return true.
(info iresolver.RPCInfo)
| 91 | |
| 92 | // Match returns true if all matchers return true. |
| 93 | func (a *CompositeMatcher) Match(info iresolver.RPCInfo) bool { |
| 94 | if a.pm != nil && !a.pm.match(info.Method) { |
| 95 | return false |
| 96 | } |
| 97 | |
| 98 | // Call headerMatchers even if md is nil, because routes may match |
| 99 | // non-presence of some headers. |
| 100 | var md metadata.MD |
| 101 | if info.Context != nil { |
| 102 | md, _ = metadata.FromOutgoingContext(info.Context) |
| 103 | if extraMD, ok := grpcutil.ExtraMetadata(info.Context); ok { |
| 104 | md = metadata.Join(md, extraMD) |
| 105 | // Remove all binary headers. They are hard to match with. May need |
| 106 | // to add back if asked by users. |
| 107 | for k := range md { |
| 108 | if strings.HasSuffix(k, "-bin") { |
| 109 | delete(md, k) |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | for _, m := range a.hms { |
| 115 | if !m.Match(md) { |
| 116 | return false |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if a.fm != nil && !a.fm.match() { |
| 121 | return false |
| 122 | } |
| 123 | return true |
| 124 | } |
| 125 | |
| 126 | func (a *CompositeMatcher) String() string { |
| 127 | var ret string |
nothing calls this directly
no test coverage detected