Skip to content

Instantly share code, notes, and snippets.

@toantran-ea
Created November 30, 2019 09:53
Show Gist options
  • Select an option

  • Save toantran-ea/fa3e8be53e8c58f8083aa72174382b04 to your computer and use it in GitHub Desktop.

Select an option

Save toantran-ea/fa3e8be53e8c58f8083aa72174382b04 to your computer and use it in GitHub Desktop.
Connect attempt 1
package com.example.demo
// import
val dataRepo = DataRepository()
fun Application.main() {
// ...
post("entries") {
val entries = fromJsonStringToList(call.receiveText())
val savedKeys = dataRepo.save(entries)
call.respondText(contentType = ContentType.Application.Json) {
Json.stringify(String.serializer().list, savedKeys.map { it.id.toString() })
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment