title: Spring Cloud Gateway how to get original url when using forward://
body: <p>I'm trying to route some requests to my local controller into the Spring Cloud Gateway and process them.
  I need path part of the original url to process the request. as documentation states:</p>
  
  <blockquote>
    <p>If the url has a forward scheme (ie forward:///localendpoint), it will use the Spring DispatcherHandler to handler the request. <strong>The path part of the request URL will be overridden with the path in the forward URL</strong>. The unmodified original url is <strong>appended to the list in the ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR attribute.</strong></p>
  </blockquote>
  
  <p>When I read this attribute into my controller, I'm not  getting the original url (<code>http://somedomain.com/data_I_need/ping</code>) but already modified one:</p>
  
  <pre><code>@GetMapping(value = "/expireProlong/",produces = MediaType.APPLICATION_JSON_VALUE)
  public Mono&lt;String&gt; expireProlong(ServerWebExchange exchange) {
      exchange.getAttributes().forEach( (s, o) -&gt; System.out.println(s+" = "+o));
      return Mono.just("OK");
  }
  
  </code></pre>
  
  <p>These are logs</p>
  
  <pre><code>org.springframework.web.reactive.HandlerMapping.bestMatchingHandler = com.xxxx.gateway.controller.Controller#expireProlong(ServerWebExchange)
  //Here should be the original url `http://somedomain.com/data_I_need/ping
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.gatewayOriginalRequestUrl = [http://localhost:8182/expireProlong/]
  org.springframework.web.reactive.HandlerMapping.bestMatchingPattern = /expireProlong/
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.gatewayHandlerMapper = RoutePredicateHandlerMapping
  org.springframework.web.reactive.HandlerMapping.producibleMediaTypes = [application/json]
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.gatewayRequestUrl = forward:/expireProlong/
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.uriTemplateVariables = {}
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.routeWeight = {}
  org.springframework.web.reactive.HandlerMapping.uriTemplateVariables = {}
  org.springframework.web.server.ServerWebExchange.LOG_ID = 238ba20f
  org.springframework.web.reactive.HandlerMapping.matrixVariables = {}
  org.springframework.cloud.gateway.support.ServerWebExchangeUtils.gatewayRoute = Route{id='ExpireProlong', uri=forward:///expireProlong/, order=0, predicate=Paths: [/**/ping], match trailing slash: true, gatewayFilters=[[[RewritePath /(?&lt;remaining&gt;.*)/ping = '/expireProlong/${remaining}'], order = 1]], metadata={}}
  
  
  </code></pre>
  
  <p>This is my spring cloud config</p>
  
  <pre><code>spring:
    cloud:
      gateway:
        routes:
          - id: ExpireProlong
            predicates:
              - Path=/**/ping
            uri: forward:///expireProlong/
  </code></pre>
  
  <p>As you see the the original URL shows the modified URL</p>
  
  <blockquote>
    <p>org.springframework.cloud.gateway.support.ServerWebExchangeUtils.gatewayOriginalRequestUrl=[<a href="http://localhost:8182/expireProlong/]" rel="nofollow noreferrer">http://localhost:8182/expireProlong/]</a></p>
  </blockquote>
  
  <p>So what is the correct way to get original url data when using<code>forward://</code>scheme routing?</p>