add pkg protected resetRoutes so new mappings can be created via post to /routes

This commit is contained in:
Spencer Gibb
2014-11-26 11:00:55 -07:00
parent 8e16789ee3
commit c0903c5a22
3 changed files with 11 additions and 10 deletions

View File

@@ -45,7 +45,7 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
public void onApplicationEvent(EnvironmentChangeEvent event) {
for (String key : event.getKeys()) {
if (key.startsWith(properties.getMapping())) {
routes.set(locateRoutes());
resetRoutes();
return;
}
}
@@ -53,13 +53,20 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
public Map<String, String> getRoutes() {
if (routes.get() == null) {
routes.set(locateRoutes());
return resetRoutes();
}
return routes.get();
}
protected LinkedHashMap<String, String> locateRoutes() {
//access so ZuulHandlerMapping actuator can reset it's mappings
/*package*/ Map<String, String> resetRoutes() {
LinkedHashMap<String, String> newValue = locateRoutes();
routes.set(newValue);
return newValue;
}
protected LinkedHashMap<String, String> locateRoutes() {
LinkedHashMap<String, String> routesMap = new LinkedHashMap<>();
// Add routes for discovery services by default

View File

@@ -74,7 +74,7 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements
@ResponseBody
@ManagedOperation
public Map<String, String> reset() {
Map<String, String> routes = routeLocator.getRoutes();
Map<String, String> routes = routeLocator.resetRoutes();
registerHandlers(routes);
return routes;
}

View File

@@ -20,9 +20,3 @@ endpoints:
health:
sensitive: false
zuul:
proxy:
route:
stores: /stores
customers: /customers