https://kotlinlang.org logo
#ktor
Title
# ktor
b

bitkid

09/15/2019, 7:09 PM
how would you guys structure your REST endpoints with ktor and locationsAPI when the same object can be retrieved by different keys? so i have as an example /api/articles/{id} (id is an UUID) but the same article can be fetched by it's unique name. would you prefer something like /api/articles/by-name/{name} or /api/articles/{name}/by-name or some kind of "polymorphism" where there is a manual check if the parameter is a UUID or a name?
i know this is not really related to ktor, but i thought i ask anyway 🙂
d

Dennis Schröder

09/15/2019, 9:57 PM
Why is your api designed to have to unique identifier? (UUID and Name)
☝️ 1
b

bitkid

09/16/2019, 8:24 AM
that's a weird question .. business requires it. it's basically unique synonyms and that's the way the data is.
v

Vlad

09/16/2019, 8:29 AM
If those were the only options I would preffer
/api/articles/by-name/{name}
, else
/api/articles?name={name}
b

bitkid

09/16/2019, 8:39 AM
i am open for better options 🙂
but i agree .. /api/articles/by-name/{name} is better than /api/articles/{name}/by-name