It’s not the routing algorithm, but routing builde...
# ktor
o
It’s not the routing algorithm, but routing builder. It doesn’t work as you expect, and rightfully we should employ DslMarker to prevent such problems. Thanks for an example! What’s happening here is that
contentType
is not bound to
get
but instead to the routing root (because of receiver match rules). What in fact happens is this:
Copy code
routing {
            contentType(ContentType.Application.Json) {
                println("JSON, as expected")
            }
            contentType(ContentType.Video.MP4) {
                println("Will never happen, we are safe")
                throw Exception("Oops, I didn't expected this branch to be executed!!")
            }
        get("/v1") {
            call.respond(JsonResponse(model))
        }