title: Can't mount routes, even though registerRoute function is called
body: <p>I'm trying to write a simple Ktor app. I've got a file called <code>ImageRoutes.kt</code>:</p>
  <pre><code>package my.keddad.routes
  
  // some imports here
  
  fun Route.imageRouting() {
      route(&quot;/image&quot;) {
          post {
              // some logic here
          }
      }
  }
  
  fun Application.registerImageRoutes() {
      routing {
          imageRouting()
      }
  }
  </code></pre>
  <p>I want to mount those routes. To do so, I add my <code>registerImageRoutes()</code> function to <code>embeddedServer</code> configuration. My <code>Application.kt</code>:</p>
  <pre><code>package my.keddad
  
  import io.ktor.application.*
  import io.ktor.server.engine.*
  import io.ktor.server.netty.*
  import my.keddad.plugins.*
  import my.keddad.routes.registerImageRoutes
  
  fun main() {
      embeddedServer(Netty, port = 8080, host = &quot;0.0.0.0&quot;) {
          configureRouting()
          configureHTTP()
          configureMonitoring()
          configureSerialization()
          registerImageRoutes()
      }.start(wait = true)
  }
  </code></pre>
  <p>When I start my code, <code>registerImageRoutes</code> function is called, but, apperently, no routes are added - I get 404 errors when trying to use them:</p>
  <pre><code>2021-12-01 00:45:37.015 [main] INFO  ktor.application - Autoreload is disabled because the development mode is off.
  2021-12-01 00:45:37.083 [main] INFO  ktor.application - Responding at http://0.0.0.0:8080
  2021-12-01 00:45:37.083 [main] INFO  ktor.application - Application started in 0.079 seconds.
  2021-12-01 00:45:37.084 [main] INFO  ktor.application - Application started: io.ktor.application.Application@1a677343
  2021-12-01 00:45:39.699 [eventLoopGroupProxy-4-1] INFO  ktor.application - 404 Not Found: post - /image
  </code></pre>
  <p>Documentation also suggests adding my route registration function to <code>Application.module</code>, however, that also doesn't work. What am I doing wrong?</p>
  <p>Here is how my trace looks like:</p>
  <pre><code>2021-12-01 10:02:54.375 [eventLoopGroupProxy-4-1] TRACE ktor.application - Trace for [image]
  /, segment:0 -&gt; SUCCESS @ /
    /image, segment:1 -&gt; SUCCESS @ /image
      /image/(method:POST), segment:1 -&gt; FAILURE &quot;Selector didn't match&quot; @ /image/(method:POST)
  Matched routes:
    No results
  Route resolve result:
    FAILURE &quot;No matched subtrees found&quot; @ /
  </code></pre>
  <p>I'm not sure what that means. It does know that there is a <code>/image</code> route registered, but it can't find the handler for POST to that URI?</p>
  <p>Actually, it looks like it has something to do with request type. When running tests, like this:</p>
  <pre><code> withTestApplication({ configureRouting() }) {
              with(handleRequest(HttpMethod.Post, &quot;/image&quot;){
  ...
  
              }
  </code></pre>
  <p>I get 404. When using curl like this:</p>
  <pre><code>curl -v -X post http://localhost:8080/image
  </code></pre>
  <p>I also get 404. However, when using curl with &quot;post&quot; in capital letters, it does work as expected:</p>
  <pre><code>curl -v -X POST http://localhost:8080/image
  </code></pre>
  <p>I'm also confused by the trace, which looks just like the trace for failed requests (with the exception of it actually finding the route):</p>
  <pre><code>2021-12-01 11:21:33.369 [eventLoopGroupProxy-4-2] TRACE ktor.application - Trace for [image]
  /, segment:0 -&gt; SUCCESS @ /
    /image, segment:1 -&gt; SUCCESS @ /image
      /image/(method:POST), segment:1 -&gt; SUCCESS @ /image/(method:POST)
  Matched routes:
    &quot;&quot; -&gt; &quot;image&quot; -&gt; &quot;(method:POST)&quot;
  Route resolve result:
    SUCCESS @ /image/(method:POST)
  </code></pre>