Parsing sources is slightly against <#C0A974TJ9|kt...
# ktor
o
Parsing sources is slightly against #ktor and Kotlin in general, because functional composition can easily break it. E.g. if instead of having a seprate route for
pet
,
category
,
city
, etc I could make a loop something like this:
Copy code
val restEntities = mapOf("pets" to Pet::class, “category” to Category::class, …)
routes {
   restEntities.forEach { (path, type) ->
     get(path) { call.respondJson(repository.list(type) }
     post(path) { repository.add(call.request.content.toJson(type)) }
     …
   }
}
Something like this