Allow easier subclassing of SimpleRouteLocator
Fixes gh-1598
This commit is contained in:
committed by
Spencer Gibb
parent
fe06370aa2
commit
73b5609e63
@@ -83,6 +83,11 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
|
||||
@Override
|
||||
public Route getMatchingRoute(final String path) {
|
||||
|
||||
return getSimpleMatchingRoute(path);
|
||||
|
||||
}
|
||||
|
||||
protected Route getSimpleMatchingRoute(final String path) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Finding route for path: " + path);
|
||||
}
|
||||
@@ -102,29 +107,31 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
|
||||
|
||||
String adjustedPath = adjustPath(path);
|
||||
|
||||
ZuulRoute route = null;
|
||||
ZuulRoute route = getZuulRoute(adjustedPath);
|
||||
|
||||
return getRoute(route, adjustedPath);
|
||||
}
|
||||
|
||||
protected ZuulRoute getZuulRoute(String adjustedPath) {
|
||||
if (!matchesIgnoredPatterns(adjustedPath)) {
|
||||
for (Entry<String, ZuulRoute> entry : this.routes.get().entrySet()) {
|
||||
String pattern = entry.getKey();
|
||||
log.debug("Matching pattern:" + pattern);
|
||||
if (this.pathMatcher.match(pattern, adjustedPath)) {
|
||||
route = entry.getValue();
|
||||
break;
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("route matched=" + route);
|
||||
}
|
||||
|
||||
return getRoute(route, adjustedPath);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Route getRoute(ZuulRoute route, String path) {
|
||||
protected Route getRoute(ZuulRoute route, String path) {
|
||||
if (route == null) {
|
||||
return null;
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("route matched=" + route);
|
||||
}
|
||||
String targetPath = path;
|
||||
String prefix = this.properties.getPrefix();
|
||||
if (path.startsWith(prefix) && this.properties.isStripPrefix()) {
|
||||
|
||||
Reference in New Issue
Block a user