Commit 472b9d17 by Spencer Gibb

Don't run PreDecorationFilter if serviceId already set.

fixes gh-695
parent 8a2a608a
...@@ -58,7 +58,8 @@ public class PreDecorationFilter extends ZuulFilter { ...@@ -58,7 +58,8 @@ public class PreDecorationFilter extends ZuulFilter {
@Override @Override
public boolean shouldFilter() { public boolean shouldFilter() {
RequestContext ctx = RequestContext.getCurrentContext(); RequestContext ctx = RequestContext.getCurrentContext();
return !ctx.containsKey("forward.to"); return !ctx.containsKey("forward.to") // another filter has already forwarded
&& !ctx.containsKey("serviceId"); // another filter has already determined serviceId
} }
@Override @Override
......
...@@ -69,6 +69,18 @@ public class PreDecorationFilterTests { ...@@ -69,6 +69,18 @@ public class PreDecorationFilterTests {
} }
@Test @Test
public void skippedIfServiceIdSet() throws Exception {
RequestContext.getCurrentContext().set("serviceId", "myservice");
assertEquals(false, this.filter.shouldFilter());
}
@Test
public void skippedIfForwardToSet() throws Exception {
RequestContext.getCurrentContext().set("forward.to", "mycontext");
assertEquals(false, this.filter.shouldFilter());
}
@Test
public void prefixRouteAddsHeader() throws Exception { public void prefixRouteAddsHeader() throws Exception {
this.properties.setPrefix("/api"); this.properties.setPrefix("/api");
this.properties.setStripPrefix(true); this.properties.setStripPrefix(true);
......
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