!str #15076 Make foreach a terminal operation, returning Future[Unit]
This commit is contained in:
parent
f4bc1704d3
commit
fdc5532483
16 changed files with 278 additions and 232 deletions
|
|
@ -32,12 +32,12 @@ class HttpServerExampleSpec
|
|||
val bindingFuture = IO(Http) ? Http.Bind(interface = "localhost", port = 8080)
|
||||
bindingFuture foreach {
|
||||
case Http.ServerBinding(localAddress, connectionStream) ⇒
|
||||
Flow(connectionStream).foreach {
|
||||
Flow(connectionStream).foreach({
|
||||
case Http.IncomingConnection(remoteAddress, requestProducer, responseConsumer) ⇒
|
||||
println("Accepted new connection from " + remoteAddress)
|
||||
|
||||
// handle connection here
|
||||
}.consume(materializer)
|
||||
}, materializer)
|
||||
}
|
||||
//#bind-example
|
||||
}
|
||||
|
|
@ -74,12 +74,12 @@ class HttpServerExampleSpec
|
|||
// ...
|
||||
bindingFuture foreach {
|
||||
case Http.ServerBinding(localAddress, connectionStream) ⇒
|
||||
Flow(connectionStream).foreach {
|
||||
Flow(connectionStream).foreach({
|
||||
case Http.IncomingConnection(remoteAddress, requestProducer, responseConsumer) ⇒
|
||||
println("Accepted new connection from " + remoteAddress)
|
||||
|
||||
Flow(requestProducer).map(requestHandler).produceTo(responseConsumer, materializer)
|
||||
}.consume(materializer)
|
||||
}, materializer)
|
||||
}
|
||||
//#full-server-example
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue