title: Ktor Routing: How to factorize the routing functionality in an application/api?
body: <p>My question is about the big picture behind routing functionality in Ktor; and scalability when it comes to design an API with large number of routes. </p>
  
  <p>If I create an app like this: </p>
  
  <pre><code>import io.ktor.application.*
  import io.ktor.response.*
  import io.ktor.request.*
  import io.ktor.server.engine.embeddedServer
  import io.ktor.server.netty.Netty
  
  fun Application.routingExample() {
   intercept(ApplicationCallPipeline.Call){
     if (call.request.uri == "/") call.respondText("User call for /")
   }
  }
  
  fun main(args: Array&lt;String&gt;) {
      embeddedServer(Netty, 8080, watchPaths = listOf("Routing"), module = Application::routingExample).start()
  }
  </code></pre>
  
  <p>Which is ok if I have an api/app with low number of routes. However in what style I should scale this approach for 
  large number of routes (e.g., 30 routes and controller functions). </p>
  
  <p>I would have a number of choices: </p>
  
  <p><strong>A large routing function</strong>: I would have a large <code>Application.routingExample</code> function that would hold all the routes, so I don't need to update the main.</p>
  
  <p><strong>A large main function</strong>:  Would have a large function that would hold the calls to different smaller functions; but it would be repetitive; as for an API I want to 
  serve them in the same port.  </p>
  
  <p>So my question is about the coding style: is there a way to to factorize the routing controller relationship?</p>