From 4a98f8335f2adb7b07515b76879ee091de0f1c52 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Sat, 14 Mar 2015 11:41:45 -0700 Subject: [PATCH] !htc #16972 harmonize naming - bindAndHandle... --- .../src/main/scala/akka/http/Http.scala | 34 +++++++++---------- .../scala/akka/http/ClientServerSpec.scala | 4 +-- .../src/test/scala/akka/http/TestServer.scala | 2 +- .../scala/akka/http/server/TestServer.scala | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/akka-http-core/src/main/scala/akka/http/Http.scala b/akka-http-core/src/main/scala/akka/http/Http.scala index cdd6770272..69f3d0e63f 100644 --- a/akka-http-core/src/main/scala/akka/http/Http.scala +++ b/akka-http-core/src/main/scala/akka/http/Http.scala @@ -60,11 +60,11 @@ class HttpExt(config: Config)(implicit system: ActorSystem) extends akka.actor.E * connections are being accepted at maximum rate, which, depending on the applications, might * present a DoS risk! */ - def bindAndStartHandlingWith(handler: Flow[HttpRequest, HttpResponse, _], - interface: String, port: Int = 80, backlog: Int = 100, - options: immutable.Traversable[Inet.SocketOption] = Nil, - settings: Option[ServerSettings] = None, - log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = { + def bindAndHandle(handler: Flow[HttpRequest, HttpResponse, _], + interface: String, port: Int = 80, backlog: Int = 100, + options: immutable.Traversable[Inet.SocketOption] = Nil, + settings: Option[ServerSettings] = None, + log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = { bind(interface, port, backlog, options, settings, log).toMat(Sink.foreach { conn ⇒ conn.flow.join(handler).run() })(Keep.left).run() @@ -77,12 +77,12 @@ class HttpExt(config: Config)(implicit system: ActorSystem) extends akka.actor.E * connections are being accepted at maximum rate, which, depending on the applications, might * present a DoS risk! */ - def bindAndStartHandlingWithSyncHandler(handler: HttpRequest ⇒ HttpResponse, - interface: String, port: Int = 80, backlog: Int = 100, - options: immutable.Traversable[Inet.SocketOption] = Nil, - settings: Option[ServerSettings] = None, - log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = - bindAndStartHandlingWith(Flow[HttpRequest].map(handler), interface, port, backlog, options, settings, log) + def bindAndHandleSync(handler: HttpRequest ⇒ HttpResponse, + interface: String, port: Int = 80, backlog: Int = 100, + options: immutable.Traversable[Inet.SocketOption] = Nil, + settings: Option[ServerSettings] = None, + log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = + bindAndHandle(Flow[HttpRequest].map(handler), interface, port, backlog, options, settings, log) /** * Materializes the `connections` [[Source]] and handles all connections with the given flow. @@ -91,12 +91,12 @@ class HttpExt(config: Config)(implicit system: ActorSystem) extends akka.actor.E * connections are being accepted at maximum rate, which, depending on the applications, might * present a DoS risk! */ - def startHandlingWithAsyncHandler(handler: HttpRequest ⇒ Future[HttpResponse], - interface: String, port: Int = 80, backlog: Int = 100, - options: immutable.Traversable[Inet.SocketOption] = Nil, - settings: Option[ServerSettings] = None, - log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = - bindAndStartHandlingWith(Flow[HttpRequest].mapAsync(handler), interface, port, backlog, options, settings, log) + def bindAndHandleAsync(handler: HttpRequest ⇒ Future[HttpResponse], + interface: String, port: Int = 80, backlog: Int = 100, + options: immutable.Traversable[Inet.SocketOption] = Nil, + settings: Option[ServerSettings] = None, + log: LoggingAdapter = system.log)(implicit fm: FlowMaterializer): Future[ServerBinding] = + bindAndHandle(Flow[HttpRequest].mapAsync(handler), interface, port, backlog, options, settings, log) /** * Transforms a given HTTP-level server [[Flow]] into a lower-level TCP transport flow. diff --git a/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala b/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala index 08efbb0fcd..6eaf982c09 100644 --- a/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala @@ -77,9 +77,9 @@ class ClientServerSpec extends WordSpec with Matchers with BeforeAndAfterAll { } } - "run with bindAndStartHandlingWith" in { + "run with bindAndHandle" in { val (hostname, port) = temporaryServerHostnameAndPort() - val binding = Http().bindAndStartHandlingWith(Flow[HttpRequest].map(_ ⇒ HttpResponse()), hostname, port) + val binding = Http().bindAndHandle(Flow[HttpRequest].map(_ ⇒ HttpResponse()), hostname, port) val b1 = Await.result(binding, 3.seconds) val (_, f) = Http().outgoingConnection(hostname, port) diff --git a/akka-http-core/src/test/scala/akka/http/TestServer.scala b/akka-http-core/src/test/scala/akka/http/TestServer.scala index 810accf621..c22be6dee9 100644 --- a/akka-http-core/src/test/scala/akka/http/TestServer.scala +++ b/akka-http-core/src/test/scala/akka/http/TestServer.scala @@ -18,7 +18,7 @@ object TestServer extends App { implicit val system = ActorSystem("ServerTest", testConf) implicit val fm = ActorFlowMaterializer() - val binding = Http().bindAndStartHandlingWithSyncHandler({ + val binding = Http().bindAndHandleSync({ case HttpRequest(GET, Uri.Path("/"), _, _, _) ⇒ index case HttpRequest(GET, Uri.Path("/ping"), _, _, _) ⇒ HttpResponse(entity = "PONG!") case HttpRequest(GET, Uri.Path("/crash"), _, _, _) ⇒ sys.error("BOOM!") diff --git a/akka-http-tests/src/test/scala/akka/http/server/TestServer.scala b/akka-http-tests/src/test/scala/akka/http/server/TestServer.scala index bb9717a1b6..4c38d94811 100644 --- a/akka-http-tests/src/test/scala/akka/http/server/TestServer.scala +++ b/akka-http-tests/src/test/scala/akka/http/server/TestServer.scala @@ -28,7 +28,7 @@ object TestServer extends App { case _ ⇒ false } - val bindingFuture = Http().bindAndStartHandlingWith({ + val bindingFuture = Http().bindAndHandle({ get { path("") { complete(index)