1

尝试创建 http 客户端/流时,此代码似乎不再起作用:

lazy val myConnectionFlow = 
 Http().outgoingConnection("localhost", port).flow

def myRequest(request: HttpRequest): Future[HttpResponse] = 
 Source.single(request).via(myConnectionFlow).runWith(Sink.head)

flow方法似乎不再可用。它真的被弃用了吗?以下是现在创建 Http 连接的首选方式吗?

 val connFlow: Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]] =
  Http().outgoingConnection("localhost", port)

 val responseFuture: Future[HttpResponse] =
  Source.single(HttpRequest(uri="XXX"))
  .via(connFlow).runWith(Sink.head)
4

1 回答 1

0

是的。实验模块没有弃用期,尤其是在达到 1.0 之前。

于 2015-08-15T07:47:34.290 回答