Don't run PreDecorationFilter if serviceId already set.
fixes gh-695
This commit is contained in:
@@ -58,7 +58,8 @@ public class PreDecorationFilter extends ZuulFilter {
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
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
|
||||
|
||||
@@ -68,6 +68,18 @@ public class PreDecorationFilterTests {
|
||||
assertEquals("pre", this.filter.filterType());
|
||||
}
|
||||
|
||||
@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 {
|
||||
this.properties.setPrefix("/api");
|
||||
|
||||
Reference in New Issue
Block a user