There's a route that goes somewhat like this:
val route =
path("data") {
get {
val src: Source[ByteString, BoundedSourceQueue[ByteString]] = ???
complete(HttpEntity(ContentTypes.`application/octet-stream`, src))
}
}
How can I access materialised value of this source?
Prematerializing src
should do the trick.
// will need an implicit ActorSystem/ActorMaterializer in scope
val baseSrc: Source[ByteString, BoundedSourceQueue[ByteString]] = ???
val (bsq, src) = baseSrc.preMaterialize()
// do stuff with bsq...
complete(HttpEntity(ContentTypes.`application/octet-stream`, src))