>
> Thanks for the clarification... the new API is very different. I need to
> let this whole flows thing sink in a bit, but I kinda see where its going.
> Granted this is just one use case but I am a little concerned about all
> the machinery needed to perform something pretty simple, a GET request in
> this case. Not sure if I'm doing this right but I end up awaiting twice to
> get the content I need out of the response--like the code below. It does
> work... Just appears quite a bit more complex than the Spray version.
>
>
def httpGet( uri:String )(implicit s:ActorSystem) = { // returns
(status_code, entity_as_string)
implicit val materializer = FlowMaterializer()
var r:HttpResponse = null
val req = HttpRequest(HttpMethods.GET, Uri(uri))
val host:String = req.uri.authority.host.toString
val port:Int = req.uri.effectivePort
val httpClient = Http().outgoingConnection(host,port).flow
val consumer = Sink.foreach[HttpResponse] { resp ⇒ r = resp }
val finishFuture = Source.single(req).via(httpClient).runWith(consumer)
Await.result(finishFuture, Duration("3 seconds"))
// unpack result
(r.status.intValue,
Await.result(r.entity.toStrict(FiniteDuration(3,"seconds")), Duration("3
seconds") ).data.utf8String)
}
>
>
--
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.