Join Slack
Powered by
What is the kotlin way to deal with `@Location`s w...
# ktor
l
leus
03/05/2018, 7:12 PM
What is the kotlin way to deal with `@Location`s when you have many routes?
leus
03/05/2018, 7:15 PM
For example, you have "/", "/v1/api/somecall/{param}", and these with get and post
o
orangy
03/06/2018, 7:32 AM
I don’t quite understand the question, you just create more location classes and use them?
l
leus
03/06/2018, 3:00 PM
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?
leus
03/06/2018, 3:01 PM
also, do locations support post() to URLs which also contain some
{variable}
?
o
orangy
03/06/2018, 3:28 PM
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
Deactivated User
03/12/2018, 12:01 PM
Just wrote a bit about the locations feature:
http://ktor.io/features/locations.html
Open in Slack
Previous
Next