Ktor Version and Engine Used (client or server and name)
Ktor v1.2.3, TestApplicationEngine
Describe the bug
I am building a Feature for rest repositories, when registering the routes for a specified HttpMethod, the lambda passed to the handle method is never executed. Here my repo's issue
To Reproduce
Here's the code to reproduce it. Strangely the response is null, check out the test results on TravisCI here .
May be related to this.
The first bug I've noticed is in Utils.kt lines 49 and 61: entityIdTag should be placed inside of {}, otherwise it leads to a constant path requirement, for example, repositories/intidentities/entityIdTag that is never requested, should be
repositories/intidentities/{entityIdTag}.
After fixing this, integer entities test still no luck: the second request is PUT, but your repository is creating POST routes instead.
Also, when sending a request body, one should also provide Content-Type request header. Otherwise, a server may respond with 415 Unsupported Media Type.
Also, you can use routing resolution trace for debugging complex routing trees:
routing {
trace { trace ->
println(trace.buildText())
}
}
Thank you very much! Using the trace function (which I was not aware at all) I discovered that the problems were indeed the Content-Type for multiple items and the forgotten parenthesis for both single and multiple items!