Commit c0903c5a by Spencer Gibb

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

parent 8e16789e
...@@ -45,7 +45,7 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent> ...@@ -45,7 +45,7 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
public void onApplicationEvent(EnvironmentChangeEvent event) { public void onApplicationEvent(EnvironmentChangeEvent event) {
for (String key : event.getKeys()) { for (String key : event.getKeys()) {
if (key.startsWith(properties.getMapping())) { if (key.startsWith(properties.getMapping())) {
routes.set(locateRoutes()); resetRoutes();
return; return;
} }
} }
...@@ -53,12 +53,19 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent> ...@@ -53,12 +53,19 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
public Map<String, String> getRoutes() { public Map<String, String> getRoutes() {
if (routes.get() == null) { if (routes.get() == null) {
routes.set(locateRoutes()); return resetRoutes();
} }
return routes.get(); return routes.get();
} }
//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() { protected LinkedHashMap<String, String> locateRoutes() {
LinkedHashMap<String, String> routesMap = new LinkedHashMap<>(); LinkedHashMap<String, String> routesMap = new LinkedHashMap<>();
......
...@@ -74,7 +74,7 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements ...@@ -74,7 +74,7 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements
@ResponseBody @ResponseBody
@ManagedOperation @ManagedOperation
public Map<String, String> reset() { public Map<String, String> reset() {
Map<String, String> routes = routeLocator.getRoutes(); Map<String, String> routes = routeLocator.resetRoutes();
registerHandlers(routes); registerHandlers(routes);
return routes; return routes;
} }
......
...@@ -20,9 +20,3 @@ endpoints: ...@@ -20,9 +20,3 @@ endpoints:
health: health:
sensitive: false sensitive: false
zuul:
proxy:
route:
stores: /stores
customers: /customers
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