title: Spring Cloud Gateway 2.0 forward path variable
body: <p>How to forward a path variable in Spring Cloud Gateway 2.0?</p>
  
  <p>If we have an microservice that has 2 endpoints: <code>/users</code> and <code>/users/{id}</code> and is running on port 8080, how to forward the request to the endpoint with the id path variable?</p>
  
  <p>The following gateway configuration successfully forwards to the <code>/users</code> end point, but the second route forwards the request to the same <code>/users</code> endpoint of the real service.</p>
  
  <pre><code>@Bean
  public RouteLocator routes(RouteLocatorBuilder builder) {
      return builder.routes()
          .route("users", t -&gt; t.path("/users").uri("http://localhost:8080/users"))
          .route("userById", t -&gt; t.path("/users/**").uri("http://localhost:8080/users/"))
          .build();
  }
  </code></pre>
  
  <p>I'm using <code>spring-cloud-starter-gateway</code> from spring cloud <code>Finchley.BUILD-SNAPSHOT</code></p>