Skip to content

Commit

Permalink
Merge pull request #76 from jrudolph/akka-http-10.2.0
Browse files Browse the repository at this point in the history
Upgrade to Akka HTTP 10.2.0
  • Loading branch information
jrudolph authored Aug 6, 2020
2 parents fc5aef0 + dac193b commit d9571bd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.3
sbt.version=1.3.13
2 changes: 1 addition & 1 deletion src/main/g8/default.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/g8/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.3
sbt.version=1.3.13
8 changes: 3 additions & 5 deletions src/main/g8/src/main/scala/$package$/QuickstartApp.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit d9571bd

Please sign in to comment.