Is there any way to automatically add defined routes at compile-time (or runtime) without having to explicitly add them in the application module definition?
Not only does it get tedious, it's also error prone if you forget to register a defined route. I assume it should be possible with code-generation or annotation processing such as kapt, but I'm wondering if anyone has already done something like this?
b
Big Chungus
09/05/2022, 1:15 PM
Have you tried ktor locations feature?
i
Ivan Đorđević
09/05/2022, 2:23 PM
@Big Chungus
The documentation says it's deprecated and instead points to
Resources
plugin.
But from what I gathered from reading the
Resources
documentation, I'd have to put all routes in a certain hierarchy as inner/nested classes.
Afaik Kotlin has no way to externally create a nested class, right? That means that all routes in a single hierarchy would then need to be defined in a single file 😞