title: Spring Web Flux (reactive) functional route not working as expected with Kotlin
body: <p>Hello good people interested in writing spring apps in Kotlin. I am playing with Spring Boot 2.0.0 snapshot and <code>spring-webflux</code>. This piece of code:</p>
  
  <pre><code>@Component
  class TestRouter() : RouterFunction&lt;ServerResponse&gt; {
    override fun route(request: ServerRequest) = route(request) {
      "/".route {
        GET("/hello") { ServerResponse.ok().body(BodyInserters.fromObject("World")) }
        "/{id}".route {
          GET("/hello") { ServerResponse.ok().body(BodyInserters.fromObject("World ${request.pathVariable("id")}")) }
        }
      }
    }
  }
  </code></pre>
  
  <p>does not work as expected (at least as I would expect:))</p>
  
  <pre><code>➜  ~ curl -i http://localhost:8080/hello
  HTTP/1.1 200 OK
  transfer-encoding: chunked
  Content-Type: text/plain;charset=UTF-8
  
  World
  </code></pre>
  
  <p>but:</p>
  
  <pre><code>➜  ~ curl -i http://localhost:8080/1/hello
  HTTP/1.1 404 Not Found
  content-length: 0
  </code></pre>
  
  <p>Working case trace:</p>
  
  <pre><code>2017-03-03 00:58:03.865 TRACE 7666 --- [ctor-http-nio-4] o.s.w.r.f.server.RequestPredicates       : Pattern "//**" matches against value "/hello"
  2017-03-03 00:58:03.865 DEBUG 7666 --- [ctor-http-nio-4] o.s.w.r.function.server.RouterFunctions  : Nested predicate "//**" matches against "GET /hello"
  2017-03-03 00:58:03.865 TRACE 7666 --- [ctor-http-nio-4] o.s.w.r.f.server.RequestPredicates       : Method "GET" matches against value "GET"
  2017-03-03 00:58:03.866 TRACE 7666 --- [ctor-http-nio-4] o.s.w.r.f.server.RequestPredicates       : Pattern "/hello" matches against value "/hello"
  2017-03-03 00:58:03.866 DEBUG 7666 --- [ctor-http-nio-4] o.s.w.r.function.server.RouterFunctions  : Predicate "(GET &amp;&amp; /hello)" matches against "GET /hello"
  </code></pre>
  
  <p>Not working case trace:</p>
  
  <pre><code>2017-03-03 00:59:26.958 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Pattern "//**" matches against value "/1/hello"
  2017-03-03 00:59:26.958 DEBUG 7666 --- [ctor-http-nio-1] o.s.w.r.function.server.RouterFunctions  : Nested predicate "//**" matches against "GET /1/hello"
  2017-03-03 00:59:26.958 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Method "GET" matches against value "GET"
  2017-03-03 00:59:26.958 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Pattern "/hello" does not match against value "/1/hello"
  2017-03-03 00:59:26.959 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Pattern "/{id}/**" matches against value "/1/hello"
  2017-03-03 00:59:26.959 DEBUG 7666 --- [ctor-http-nio-1] o.s.w.r.function.server.RouterFunctions  : Nested predicate "/{id}/**" matches against "GET /1/hello"
  2017-03-03 00:59:26.959 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Method "GET" matches against value "GET"
  2017-03-03 00:59:26.959 TRACE 7666 --- [ctor-http-nio-1] o.s.w.r.f.server.RequestPredicates       : Pattern "/hello" does not match against value "/1/hello"
  </code></pre>
  
  <p>This seems like a bug (as the <code>"/{id}".route {...}</code> supposedly is using RouterFunctions.nest), but I could be wrong. Your thoughts and help are welcome.</p>
  
  <p>I obviously know that I can make <code>/1/hello</code> work by just writing <code>GET("/{id}/hello") { ... }</code>, but I am interested in the nested <code>.route { ...}</code> variant as it supports my use case of adding nested routes from another location (like a map, etc). </p>