8

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.

S.Karthik
  • 1,389
  • 9
  • 21
  • Sick returns a ReactiveStream publisher. So this is more of a akka question than a Slick question. Just FYI. – cvogt Apr 15 '15 at 20:34

1 Answers1

2

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))
         }
S.Karthik
  • 1,389
  • 9
  • 21