I am using slick 3.0 and have a databasepublisher object as
def getAsStream = db.stream[Entity](tblquery.result)
I am using akka-http for rest layer as follows,
val route =
path("stream"){
get {
complete { // how to stream from here }
}
}
How can I use this databasepublisher object, to transform(json) and stream each row to the client. Please help.
I finally doing something like this, do not know whether its right way,
complete {
val source = Source(repository.getAsStream).map(a => ChunkStreamPart(a.asJson))
HttpResponse(entity = HttpEntity.Chunked(MediaTypes.`application/json`, source))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With