What is the kotlin way to deal with `@Location`s w...
# ktor
l
What is the kotlin way to deal with `@Location`s when you have many routes?
For example, you have "/", "/v1/api/somecall/{param}", and these with get and post
o
I don’t quite understand the question, you just create more location classes and use them?
l
I guess that's what I'm wondering - if I have two different routes, "/path1/" and "/path2", do I need an empty class for each?
also, do locations support post() to URLs which also contain some
{variable}
?
o
Yep, empty page is of no help… http://ktor.io/features/locations.html Short answer is that you need to have a separate location class for each endpoint, and yes of course, path variables and query parameters are supported You can get an idea of how it all works from the sample: https://github.com/ktorio/ktor/blob/master/ktor-samples/ktor-samples-locations/src/io/ktor/samples/locations/LocationsApplication.kt and tests: https://github.com/ktorio/ktor/blob/master/ktor-features/ktor-locations/test/io/ktor/tests/locations/LocationsTest.kt
d
Just wrote a bit about the locations feature: http://ktor.io/features/locations.html