From dac193bdd919ad6b13c8a50ebbc48c44f30929f9 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Wed, 5 Aug 2020 15:49:40 +0200 Subject: [PATCH] Upgrade to Akka HTTP 10.2.0 --- README.md | 4 ++-- project/build.properties | 2 +- src/main/g8/default.properties | 2 +- src/main/g8/project/build.properties | 2 +- src/main/g8/src/main/scala/$package$/QuickstartApp.scala | 8 +++----- src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala | 3 +-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7ba9a17..0d3e301 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ page. Prerequisites: - JDK 8 -- sbt 0.13.13 or higher +- sbt 1.3.x or higher Open a console and run the following command to apply this template: ``` -sbt -Dsbt.version=1.2.8 new akka/akka-http-quickstart-scala.g8 +sbt -Dsbt.version=1.3.13 new akka/akka-http-quickstart-scala.g8 ``` This template will prompt for the following parameters. Press `Enter` if the default values suit you: diff --git a/project/build.properties b/project/build.properties index 6adcdc7..0837f7a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.3 +sbt.version=1.3.13 diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index 22f0fc1..9e89a1d 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -1,6 +1,6 @@ name=My Akka HTTP Project description=This is a seed project which creates a basic build for an Akka HTTP application using Scala. -scala_version=2.13.1 +scala_version=2.13.3 akka_http_version=maven(com.typesafe.akka, akka-http-core_2.13, stable) akka_version=maven(com.typesafe.akka, akka-actor-typed_2.13, stable) organization=com.example diff --git a/src/main/g8/project/build.properties b/src/main/g8/project/build.properties index 6adcdc7..0837f7a 100644 --- a/src/main/g8/project/build.properties +++ b/src/main/g8/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.3 +sbt.version=1.3.13 diff --git a/src/main/g8/src/main/scala/$package$/QuickstartApp.scala b/src/main/g8/src/main/scala/$package$/QuickstartApp.scala index db59cf9..4001052 100644 --- a/src/main/g8/src/main/scala/$package$/QuickstartApp.scala +++ b/src/main/g8/src/main/scala/$package$/QuickstartApp.scala @@ -1,7 +1,6 @@ package $package$ import akka.actor.typed.ActorSystem -import akka.actor.typed.scaladsl.adapter._ import akka.actor.typed.scaladsl.Behaviors import akka.http.scaladsl.Http import akka.http.scaladsl.server.Route @@ -12,12 +11,11 @@ import scala.util.Success //#main-class object QuickstartApp { //#start-http-server - private def startHttpServer(routes: Route, system: ActorSystem[_]): Unit = { + private def startHttpServer(routes: Route)(implicit system: ActorSystem[_]): Unit = { // Akka HTTP still needs a classic ActorSystem to start - implicit val classicSystem: akka.actor.ActorSystem = system.toClassic import system.executionContext - val futureBinding = Http().bindAndHandle(routes, "localhost", 8080) + val futureBinding = Http().newServerAt("localhost", 8080).bind(routes) futureBinding.onComplete { case Success(binding) => val address = binding.localAddress @@ -35,7 +33,7 @@ object QuickstartApp { context.watch(userRegistryActor) val routes = new UserRoutes(userRegistryActor)(context.system) - startHttpServer(routes.userRoutes, context.system) + startHttpServer(routes.userRoutes)(context.system) Behaviors.empty } diff --git a/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala b/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala index 115ee55..ef1ced3 100644 --- a/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala +++ b/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala @@ -8,7 +8,6 @@ import akka.http.scaladsl.model._ import akka.http.scaladsl.testkit.ScalatestRouteTest import org.scalatest.concurrent.ScalaFutures import org.scalatest.{ Matchers, WordSpec } -import akka.actor.typed.scaladsl.adapter._ //#set-up class UserRoutesSpec extends WordSpec with Matchers with ScalaFutures with ScalatestRouteTest { @@ -19,7 +18,7 @@ class UserRoutesSpec extends WordSpec with Matchers with ScalaFutures with Scala lazy val testKit = ActorTestKit() implicit def typedSystem = testKit.system override def createActorSystem(): akka.actor.ActorSystem = - testKit.system.toClassic + testKit.system.classicSystem // Here we need to implement all the abstract members of UserRoutes. // We use the real UserRegistryActor to test it while we hit the Routes,