use of com.yahoo.jdisc.application.BindingMatch in project vespa by vespa-engine.
the class HttpConfigRequests method getBindingMatch.
/**
* Produces the binding match for the request. If it's not available on the jDisc request, create one for
* testing using the long and short app id URL patterns given.
* @param req an {@link com.yahoo.container.jdisc.HttpRequest}
* @param patterns A list of patterns that should be matched if no match on binding.
* @return match
*/
public static BindingMatch<?> getBindingMatch(HttpRequest req, String... patterns) {
com.yahoo.jdisc.http.HttpRequest jDiscRequest = req.getJDiscRequest();
if (jDiscRequest == null)
throw new IllegalArgumentException("No JDisc request for: " + req.getUri());
BindingMatch<?> jdBm = jDiscRequest.getBindingMatch();
if (jdBm != null)
return jdBm;
// If not, use provided patterns
for (String pattern : patterns) {
UriPattern fullAppIdPattern = new UriPattern(pattern);
URI uri = req.getUri();
Match match = fullAppIdPattern.match(uri);
if (match != null)
return new BindingMatch<>(match, new Object(), fullAppIdPattern);
}
throw new IllegalArgumentException("Illegal url for config request: " + req.getUri());
}
Aggregations