Returns true iff the given RouteMatch matches the RPC's full method name and headers.
(RouteMatch routeMatch, String fullMethodName,
Metadata headers, ThreadSafeRandom random)
| 144 | * headers. |
| 145 | */ |
| 146 | static boolean matchRoute(RouteMatch routeMatch, String fullMethodName, |
| 147 | Metadata headers, ThreadSafeRandom random) { |
| 148 | if (!matchPath(routeMatch.pathMatcher(), fullMethodName)) { |
| 149 | return false; |
| 150 | } |
| 151 | for (HeaderMatcher headerMatcher : routeMatch.headerMatchers()) { |
| 152 | if (!headerMatcher.matches(getHeaderValue(headers, headerMatcher.name()))) { |
| 153 | return false; |
| 154 | } |
| 155 | } |
| 156 | FractionMatcher fraction = routeMatch.fractionMatcher(); |
| 157 | return fraction == null || random.nextInt(fraction.denominator()) < fraction.numerator(); |
| 158 | } |
| 159 | |
| 160 | private static boolean matchPath(PathMatcher pathMatcher, String fullMethodName) { |
| 161 | if (pathMatcher.path() != null) { |