Hi all,
Sorry if this is a dumb question, but I'm only starting with akka-http
and don't know anything (yet) about akka-streams.
While migrating a client from spray to akka-http, I found myself doing
this kind of thing:
httpBackend.singleRequest(request).flatMap { r =>
r.entity.dataBytes.runFold(ByteString.empty)(_ ++ _).
map(_.utf8String).map { body ⇒
import DefaultJsonProtocol._
body.parseJson.asJsObject("Unknown response format " +
body)
}
}
The idea is to return a Spray JsObject from the response entity (or fail
the future if not).
But I've mostly seen examples written with the flow variant (ie
Source.single(request).mapAsync(1)).
It is my understanding that the first way materializes the stream
earlier than the second one.
But I'm wondering what are the downsides of the first approach compared
to the second one?
--
Brice Figureau <[email protected]>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.