尝试创建 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)