From 6e4a91c4dfe69840df6e974f43f28cb822abc12f Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Thu, 14 Dec 2023 09:47:05 -0800 Subject: [PATCH] Switching over to pekko-http --- build.sbt | 28 +++++++++++++--------------- project/build.properties | 2 +- project/guardrail.sbt | 10 +++++++++- src/main/scala/App.scala | 8 ++++---- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/build.sbt b/build.sbt index 213d979..1911b94 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,9 @@ Compile / guardrailTasks := List( - ScalaServer(file("petstore.yaml"), pkg="foo"), + ScalaServer(file("petstore.yaml"), pkg="foo", modules=List("pekko-http", "circe")), ) -val akkaVersion = "2.6.15" -val akkaHttpVersion = "10.2.4" +val pekkoVersion = "1.0.0" +val pekkoHttpVersion = "1.0.0" val catsVersion = "2.6.1" val circeVersion = "0.14.1" val scalatestVersion = "3.2.9" @@ -14,16 +14,14 @@ scalacOptions ++= Seq("-Ypartial-unification", "-deprecation") libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.7.30" libraryDependencies ++= Seq( - "com.typesafe.akka" %% "akka-actor" % akkaVersion, - "com.typesafe.akka" %% "akka-stream" % akkaVersion, - "com.typesafe.akka" %% "akka-http" % akkaHttpVersion, - "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion, - "io.circe" %% "circe-core" % circeVersion, - "io.circe" %% "circe-generic" % circeVersion, - "io.circe" %% "circe-parser" % circeVersion, - "javax.xml.bind" % "jaxb-api" % jaxbApiVersion, - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.typelevel" %% "cats-core" % catsVersion, + "org.apache.pekko" %% "pekko-http" % pekkoHttpVersion, + "org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpVersion, + "org.apache.pekko" %% "pekko-stream" % pekkoVersion, + "org.apache.pekko" %% "pekko-testkit" % pekkoVersion, + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-generic" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion, + "javax.xml.bind" % "jaxb-api" % jaxbApiVersion, + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.typelevel" %% "cats-core" % catsVersion, ) - -addCompilerPlugin(scalafixSemanticdb) diff --git a/project/build.properties b/project/build.properties index 19479ba..e8a1e24 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.2 +sbt.version=1.9.7 diff --git a/project/guardrail.sbt b/project/guardrail.sbt index c146a2d..efe86b1 100644 --- a/project/guardrail.sbt +++ b/project/guardrail.sbt @@ -1 +1,9 @@ -addSbtPlugin("com.twilio" % "sbt-guardrail" % "0.64.0") +addSbtPlugin("dev.guardrail" % "sbt-guardrail" % "1.0.0-SNAPSHOT") + +libraryDependencies ++= Seq( + "dev.guardrail" %% "guardrail-scala-pekko-http" % "0.1.0-SNAPSHOT", + "dev.guardrail" %% "guardrail-core" % "1.0.0-SNAPSHOT", + "dev.guardrail" %% "guardrail-scala-support" % "1.0.0-SNAPSHOT", +) + +resolvers += "Sonatype OSS Snapshots" at "https://s01.oss.sonatype.org/content/repositories/snapshots" diff --git a/src/main/scala/App.scala b/src/main/scala/App.scala index 028fd19..ab49f54 100644 --- a/src/main/scala/App.scala +++ b/src/main/scala/App.scala @@ -2,9 +2,9 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent._ import scala.concurrent.duration.Duration -import akka.actor.ActorSystem -import akka.http.scaladsl.Http -import akka.http.scaladsl.model.ContentType +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.Http +import org.apache.pekko.http.scaladsl.model.ContentType import foo.pet._ import foo.definitions.Pet @@ -32,7 +32,7 @@ object App extends App { override def updatePet(respond: PetResource.UpdatePetResponse.type)(name: String, body: Option[Pet]): Future[PetResource.UpdatePetResponse] = ??? - def getPets(respond: PetResource.GetPetsResponse.type)(name: Iterable[String], status: Option[String]) = ??? + def getPets(respond: PetResource.GetPetsResponse.type)(name: Vector[String], status: Option[String]) = ??? }) Await.result(Http().newServerAt("127.0.0.1", 8080).bindFlow(routes), Duration.Inf)