title: Zuul route from root path
body: <p>I have some microservices discovered with Eureka. Most of them provide some API.
  And I have "edge" service called "Gateway service" which is Zuul Proxy actually.
  The thing is that there is a web application. It was hosted by gateway service for a long time and there was not any problem with that.
  But right now I need to host this client on separate service behind gateway.
  It's not a problem. I created new service and put web application there. But the thing is that Zuul on gateway service have next configuration</p>
  
  <pre><code>zuul:
    ignoredServices: '*'
    prefix: /api
    sensitiveHeaders: Cookie, Set-Cookie
    routes:
      config-service:
        path: /conf/**
        serviceId: config-service
      security-service:
        path: /security/**
        serviceId: security-service
        stripPrefix: false
      request-service:
        path: /requests/**
        stripPrefix: false
  </code></pre>
  
  <p>I need to do so that user able to access web application from a root path like this <code>http://app.com/</code>.
  But right now I can access it only by <code>http://app.com/api/</code> which is completely incorrect.</p>
  
  <p>My task is:</p>
  
  <ol>
  <li>Make web app hosted on another service available from root path.</li>
  <li>It also very important that <code>/api</code> prefix remain for all other services.</li>
  </ol>
  
  <p>I tried to implement <code>ZuulFilter</code>. But looks like it does nothing with root path and runs only when there is match with any routes described above.</p>
  
  <p>How can I make this work?</p>
  
  <p><strong>UPDATE</strong>: I have a little success with <code>ZuulFilter</code>. I made it work. Here is configuration of Zuul:</p>
  
  <pre><code>zuul:
    ignoredServices: '*'
    sensitiveHeaders: Cookie, Set-Cookie
    routes:
      api: /api/**
      config-service:
        path: /conf/**
        serviceId: config-service
      security-service:
        path: /security/**
        serviceId: security-service
        stripPrefix: false
      request-service:
        path: /requests/**
        stripPrefix: false
      frontend-host-service:
        path: /**
  </code></pre>
  
  <p>And <code>ZuulFilter</code> itself</p>
  
  <pre><code>@Bean
      public ZuulFilter apiPrefixStrip(RouteLocator routeLocator) {
          return new ZuulFilter() {
  
              @Override
              public String filterType() {
                  return "pre";
              }
  
              @Override
              public int filterOrder() {
                  return 0;
              }
  
              @Override
              public boolean shouldFilter() {
                  RequestContext context = RequestContext.getCurrentContext();
                  return context.getRequest().getRequestURI().startsWith("/api");
              }
  
              @Override
              public Object run() {
                  RequestContext context = RequestContext.getCurrentContext();
                  String path = context.getRequest().getRequestURI();
                  Route route = routeLocator.getMatchingRoute(path.substring(4));
                  if (route != null) {
                      context.put("proxy",route.getId());
                      context.put("requestURI", route.getPath());
                      context.set("serviceId", route.getLocation());
                  }
                  return null;
              }
          };
      }
  </code></pre>
  
  <p>How this work:
  there is property <code>zuul.routes.api=/api/**</code> which does not do anything actually. It just allows to map all matched paths to Zuul filter chain (<a href="http://cloud.spring.io/spring-cloud-static/Camden.SR3/#_plain_embedded_zuul" rel="noreferrer">described in documentation</a>). All other routes described here is set like there is no <code>/api</code> at all. It allows to reach services like this: <code>http://app.com/requests</code> e.g. for request service.
  The <code>ZuulFilter</code> performs check for every request described in properties but it runs only if the requested URI starts with <code>/api</code> and it redirects this request same way like there is no any <code>/api</code> in path.</p>
  
  <p>It works really. But I still dont like this solution because there are endpoints without <code>/api</code> prefix still remain on gateway service. May be anybody knows how to improve it?</p>