Hi Greg,

The API doesn't look like that. Here is an example how it is supposed to
work:

import akka.actor.ActorSystem
import akka.stream.FlowMaterializer
import akka.stream.scaladsl.{ Sink, Source }
import akka.http.model.{ HttpResponse, HttpRequest }
import akka.http.Http
import scala.concurrent.Await
import scala.concurrent.duration._

// ActorSystem to execute things with
implicit val system = ActorSystem("clientsys")

// Flow materializer that executes the streams
implicit val materializer = FlowMaterializer()

// Flow representing the http client
val httpClient = Http(system).outgoingConnection("www.example.com").flow

// Consumer that will just print headers
val consumer = Sink.foreach[HttpResponse] { resp ⇒
println(resp.headers.mkString("\n")) }

// Future produced by the ForeachConsumer
val finishFuture =
Source.single(HttpRequest()).via(httpClient).runWith(consumer)

Await.result(finishFuture, 3.seconds)
system.shutdown()
system.awaitTermination()

I recommend to wait for 1.0-M2 (coming very soon) since it contains some
fixes for the http client.


On Mon, Dec 22, 2014 at 4:35 AM, tigerfoot <gzol...@gmail.com> wrote:

> Hello,
>
> I'm very excited about the new Akka streams + http features.  Migrating
> some sample code from Spray to Akka-Http I encountered a small problem in a
> utility class I use to fire http requests.  Code here:
>
> import akka.http.Http
> import akka.http.model._
>
> import akka.io.IO
> import akka.pattern.ask
> import akka.actor.ActorSystem
> import akka.util.Timeout
>
> import scala.concurrent.{ Await, Future }
> import scala.concurrent.duration._
> import scala.language.postfixOps
> import scala.concurrent.ExecutionContext.Implicits.global
>
> object Util {
> def httpGet( uri:String )(implicit s:ActorSystem, timeout:Timeout = 30
> seconds) = {
> val resp = _http( HttpRequest(HttpMethods.GET, Uri(uri)) )
> (resp.entity.toString, resp.status)
> }
> private def _http( hr:HttpRequest )(implicit s:ActorSystem,
> timeout:Timeout = 30 seconds) = {
> val response: Future[HttpResponse] = (IO(Http) ? hr).mapTo[HttpResponse]
> Await.result( response, Duration.Inf )
> }
> }
>
> I get the following error on the key line IO(...):
>
> [error]
> /Users/Greg/git/docker-exp/src/main/scala/com.gwz.dockerexp/Util.scala:66:
> inferred type arguments [akka.http.HttpExt] do not conform to method
> apply's type parameter bounds [T <: akka.io.IO.Extension]
> [error] val response: Future[HttpResponse] = (IO(Http) ?
> hr).mapTo[HttpResponse]
>
> This worked great for the Spray libs.  How can I modify this to work with
> Akka-Http, as the Http object is clearly different?
>
> Thanks!
> Greg
>
> --
> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to