Dynamic Proxying with Zuul
<p>I am trying to proxying with Zuul based on some cookies information. I presume I will have to write some filters that would achieve the filtering dynamically. <a href="https://www.bountysource.com/issues/27820518-zuul-filter-and-routing-dynamic-customizatiion" rel="nofollow">Presumably, something as describe in this thread:</a> </p>

<p>The first problem is that I am not able to get my basic test to work. I looked at the PreDecorationFilter filter and tried to model the forwarding part. This resulted in the following basic filter:</p>

<pre><code>     @Bean
 public ZuulFilter myFilter() {
     return new ZuulFilter(){
                private UrlPathHelper urlPathHelper = new UrlPathHelper();

                 @Override
                 public Object run() {
                         RequestContext ctx = RequestContext.getCurrentContext();
                         final String requestURI = this.urlPathHelper.getPathWithinApplication(ctx.getRequest());
                         ctx.put("requestURI", requestURI);
                         ctx.set("forward.to", "localhost:8983");
                         ctx.setRouteHost(null);
                         return null;
                 }

                 @Override
                 public boolean shouldFilter() {
                         return true;
                 }

                 @Override
                 public int filterOrder() {
                         return 10;
                 }

                 @Override
                 public String filterType() {
                         return "pre";
                 }};
 }
</code></pre>

<p>My problem is that this doesn't work. When I hot the Zuul from the browser, the filter gets invoked, but the forwarding doesn't really happen. I get a response with content length of 0.</p>

<p>Which pieces of the puzzle am I missing?</p>

<p>EDIT: Adding my application.yml content:</p>

<pre><code>info:
    component: Zuul Server

endpoints:
    restart:
        enabled: true
    shutdown:
       enabled: true
    health:
       sensitive: false

server:
   port: 8080

zuul:
   proxy:
      addProxyHeaders: true
   routes:
      dynamic:
          path: /dynamic/**
          url: http://route-to-nowhere.com
</code></pre>