committed by
Spencer Gibb
parent
a399cca7ce
commit
c79ac8ba19
@@ -138,6 +138,9 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
|
||||
}
|
||||
String targetPath = path;
|
||||
String prefix = this.properties.getPrefix();
|
||||
if(prefix.endsWith("/")) {
|
||||
prefix = prefix.substring(0, prefix.length() - 1);
|
||||
}
|
||||
if (path.startsWith(prefix + "/") && this.properties.isStripPrefix()) {
|
||||
targetPath = path.substring(prefix.length());
|
||||
}
|
||||
|
||||
@@ -69,6 +69,15 @@ public class SimpleRouteLocatorTests {
|
||||
assertEquals("/test/testservicea/**", locator.getRoutes().get(0).getFullPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefix() {
|
||||
ZuulProperties properties = new ZuulProperties();
|
||||
properties.setPrefix("/test/");
|
||||
RouteLocator locator = new FilteringRouteLocator("/", properties);
|
||||
properties.getRoutes().put("testservicea", new ZuulRoute("/testservicea/**", "testservicea"));
|
||||
assertEquals("/test/testservicea/**", locator.getRoutes().get(0).getFullPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getMatchingRouteFilterRouteAcceptor() {
|
||||
RouteLocator locator = new FilteringRouteLocator("/", this.zuul);
|
||||
|
||||
Reference in New Issue
Block a user