Organizing the Routes

Learn how to split all the routes into a separate file and organize the application.

We'll cover the following...

In this section, we’ll see what the idiomatic approach in Ktor is for structuring multiple routes that belong to the same domain.

Press + to interact

Our current routing block looks like this:

routing {
    get("/status") {
        ...
    }
    post("/cats") {
        ...
    }
    get("/cats") {
        ...
    }
    get("/cats/{id}") {
        ...
    }
}

It would be good if we could extract all the routes that are related to cats into a separate file. Let’s start by ...