Commit 32c0f909 by Dave Syer

Remove regex mapper properties from ZuulProperties

It is up to the user to configure a mapper if needed (one is no longer provided automatically), so it doesn't need to take up space in ZuulProperties
parent 82d8a110
...@@ -57,8 +57,6 @@ public class ZuulProperties { ...@@ -57,8 +57,6 @@ public class ZuulProperties {
private boolean ignoreLocalService = true; private boolean ignoreLocalService = true;
private RegexMapper regexMapper = new RegexMapper();
@PostConstruct @PostConstruct
public void init() { public void init() {
for (Entry<String, ZuulRoute> entry : this.routes.entrySet()) { for (Entry<String, ZuulRoute> entry : this.routes.entrySet()) {
...@@ -78,17 +76,6 @@ public class ZuulProperties { ...@@ -78,17 +76,6 @@ public class ZuulProperties {
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public static class RegexMapper {
private boolean enabled = false;
private String servicePattern = "(?<name>.*)-(?<version>v.*$)";
private String routePattern = "${version}/${name}";
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class ZuulRoute { public static class ZuulRoute {
private String id; private String id;
......
...@@ -41,6 +41,10 @@ import static org.junit.Assert.assertTrue; ...@@ -41,6 +41,10 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.MockitoAnnotations.initMocks; import static org.mockito.MockitoAnnotations.initMocks;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
* @author Dave Syer * @author Dave Syer
...@@ -63,6 +67,19 @@ public class DiscoveryClientRouteLocatorTests { ...@@ -63,6 +67,19 @@ public class DiscoveryClientRouteLocatorTests {
private ZuulProperties properties = new ZuulProperties(); private ZuulProperties properties = new ZuulProperties();
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class RegexMapper {
private boolean enabled = false;
private String servicePattern = "(?<name>.*)-(?<version>v.*$)";
private String routePattern = "${version}/${name}";
}
private RegexMapper regexMapper = new RegexMapper();
@Before @Before
public void init() { public void init() {
initMocks(this); initMocks(this);
...@@ -590,8 +607,7 @@ public class DiscoveryClientRouteLocatorTests { ...@@ -590,8 +607,7 @@ public class DiscoveryClientRouteLocatorTests {
.willReturn(Collections.singletonList(MYSERVICE)); .willReturn(Collections.singletonList(MYSERVICE));
PatternServiceRouteMapper regExServiceRouteMapper = new PatternServiceRouteMapper( PatternServiceRouteMapper regExServiceRouteMapper = new PatternServiceRouteMapper(
this.properties.getRegexMapper().getServicePattern(), this.regexMapper.getServicePattern(), this.regexMapper.getRoutePattern());
this.properties.getRegexMapper().getRoutePattern());
DiscoveryClientRouteLocator routeLocator = new DiscoveryClientRouteLocator("/", DiscoveryClientRouteLocator routeLocator = new DiscoveryClientRouteLocator("/",
this.discovery, this.properties, regExServiceRouteMapper); this.discovery, this.properties, regExServiceRouteMapper);
List<Route> routesMap = routeLocator.getRoutes(); List<Route> routesMap = routeLocator.getRoutes();
...@@ -606,8 +622,7 @@ public class DiscoveryClientRouteLocatorTests { ...@@ -606,8 +622,7 @@ public class DiscoveryClientRouteLocatorTests {
.willReturn(Collections.singletonList("rest-service-v1")); .willReturn(Collections.singletonList("rest-service-v1"));
PatternServiceRouteMapper regExServiceRouteMapper = new PatternServiceRouteMapper( PatternServiceRouteMapper regExServiceRouteMapper = new PatternServiceRouteMapper(
this.properties.getRegexMapper().getServicePattern(), this.regexMapper.getServicePattern(), this.regexMapper.getRoutePattern());
this.properties.getRegexMapper().getRoutePattern());
DiscoveryClientRouteLocator routeLocator = new DiscoveryClientRouteLocator("/", DiscoveryClientRouteLocator routeLocator = new DiscoveryClientRouteLocator("/",
this.discovery, this.properties, regExServiceRouteMapper); this.discovery, this.properties, regExServiceRouteMapper);
List<Route> routesMap = routeLocator.getRoutes(); List<Route> routesMap = routeLocator.getRoutes();
......
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