Commit 73b5609e by Luke Tornquist Committed by Spencer Gibb

Allow easier subclassing of SimpleRouteLocator

Fixes gh-1598
parent fe06370a
...@@ -83,6 +83,11 @@ public class SimpleRouteLocator implements RouteLocator, Ordered { ...@@ -83,6 +83,11 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
@Override @Override
public Route getMatchingRoute(final String path) { public Route getMatchingRoute(final String path) {
return getSimpleMatchingRoute(path);
}
protected Route getSimpleMatchingRoute(final String path) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Finding route for path: " + path); log.debug("Finding route for path: " + path);
} }
...@@ -102,29 +107,31 @@ public class SimpleRouteLocator implements RouteLocator, Ordered { ...@@ -102,29 +107,31 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
String adjustedPath = adjustPath(path); String adjustedPath = adjustPath(path);
ZuulRoute route = null; ZuulRoute route = getZuulRoute(adjustedPath);
return getRoute(route, adjustedPath);
}
protected ZuulRoute getZuulRoute(String adjustedPath) {
if (!matchesIgnoredPatterns(adjustedPath)) { if (!matchesIgnoredPatterns(adjustedPath)) {
for (Entry<String, ZuulRoute> entry : this.routes.get().entrySet()) { for (Entry<String, ZuulRoute> entry : this.routes.get().entrySet()) {
String pattern = entry.getKey(); String pattern = entry.getKey();
log.debug("Matching pattern:" + pattern); log.debug("Matching pattern:" + pattern);
if (this.pathMatcher.match(pattern, adjustedPath)) { if (this.pathMatcher.match(pattern, adjustedPath)) {
route = entry.getValue(); return entry.getValue();
break;
} }
} }
} }
if (log.isDebugEnabled()) { return null;
log.debug("route matched=" + route);
}
return getRoute(route, adjustedPath);
} }
private Route getRoute(ZuulRoute route, String path) { protected Route getRoute(ZuulRoute route, String path) {
if (route == null) { if (route == null) {
return null; return null;
} }
if (log.isDebugEnabled()) {
log.debug("route matched=" + route);
}
String targetPath = path; String targetPath = path;
String prefix = this.properties.getPrefix(); String prefix = this.properties.getPrefix();
if (path.startsWith(prefix) && this.properties.isStripPrefix()) { if (path.startsWith(prefix) && this.properties.isStripPrefix()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment