Upgrading from 1.4.3 to 1.5.2 introduces routing p...
# ktor
b
Upgrading from 1.4.3 to 1.5.2 introduces routing precedence? Hello again, when I upgraded from 1.4.3 to 1.5.2, all of my routes serving GET requests yielded a 404 on accessing them. To me it seems, that in 1.5.2 the order of registering routes has become significant, while in 1.4.3 it didn't matter. In the example below, context "/groot" yields a 404. If staticResources() is called after groot(), route "/groot" becomes available as expected. Is this behaviour by design? If so, what are the rules by which routes take precedence over each other? Can someone please look into this? Regards, Bertram
Copy code
class SomeApp {
    fun Application.main(testing: Boolean = false) {
        
        install(ContentNegotiation) {
            gson {
                setPrettyPrinting()
            }
        }  

        routing {
            underpants()       // serves context "/underpants"
            staticResources()  // serves root context "/"
            groot()            // serves context "/groot"
        }
    }
}

// Route for static context
fun Routing.staticResources() {
    // Serves frontend resources embedded in application jar
    static("/") {
        defaultResource("index.html", "web-resource")
        resources("web-resource")
    }
}

fun Routing.underpants(
) {
    route("/underpants") {
        get {
            val map: HashMap<Int, String> = hashMapOf(1 to "Collect underpants.", 2 to "?", 3 to "Profit!")
            call.respond(map)
        }
    }
}

fun Routing.groot(
) {
    route("/groot") {
        get {
            val map: HashMap<Int, String> = hashMapOf(1 to "I", 2 to "am", 3 to "Groot!")
            call.respond(map)
        }
    }
}
r
b
OK, will do so. I wasn't sure if this a feature ...
j
Every bug is in essence a feature 😄