Skip to content

Commit

Permalink
Update latest pekko-http to bring in cors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Jul 5, 2023
1 parent 44491bb commit 74fa607
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 40 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ lazy val mkBatAssemblyTask = taskKey[File]("Create a Windows bat assembly")
// TODO: Remove when Pekko has a proper release
ThisBuild / resolvers += Resolver.ApacheMavenSnapshotsRepo
ThisBuild / updateOptions := updateOptions.value.withLatestSnapshots(false)
ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshot") // TODO Remove when proper release of pekko-http-cors is made
// TODO remove this resolver when we start using released Pekko jars
ThisBuild / resolvers += "apache-staging".at("https://repository.apache.org/content/groups/staging/")

val pekkoGrpcCodegenId = s"$pekkoPrefix-codegen"
lazy val codegen = Project(id = "codegen", base = file("codegen"))
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/paradox/server/grpc-web.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ gRPC-Web endpoint with basic CORS infrastructure in place. To use CORS,
you will need to add the pekko-http-cors dependency to your project:

@@dependency[sbt,Maven,Gradle] {
group="ch.megard"
group="org.apache.pekko"
artifact="pekko-http-cors_2.12"
version="0.0.0-SNAPSHOT" // Update when proper release of pekko-http-cors is made
version="0.0.0-4456-9a4c0fc7-SNAPSHOT" // Update when proper release of pekko-http-cors is made
}

And then serve the handlers with @apidoc[WebHandler.grpcWebHandler](WebHandler$) like this:
Expand Down
6 changes: 3 additions & 3 deletions plugin-tester-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ pekkoGrpc {

repositories {
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } // TODO Remove when proper release of pekko-http-cors is made
maven { url 'https://repository.apache.org/content/groups/staging/' } // TODO remove this resolver when we start using released Pekko jars
}

def scalaFullVersion = "2.12.18"
def scalaVersion = org.gradle.util.VersionNumber.parse(scalaFullVersion)
def scalaBinaryVersion = "${scalaVersion.major}.${scalaVersion.minor}"

dependencies {
implementation group: 'ch.megard', name: "pekko-http-cors_${scalaBinaryVersion}", version: '0.0.0-SNAPSHOT'
implementation group: 'org.apache.pekko', name: "pekko-http-cors_${scalaBinaryVersion}", version: '0.0.0+4456-9a4c0fc7-SNAPSHOT'
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
testImplementation "org.apache.pekko:pekko-stream-testkit_${scalaBinaryVersion}:0.0.0+26669-ec5b6764-SNAPSHOT"
testImplementation "org.apache.pekko:pekko-stream-testkit_${scalaBinaryVersion}:1.0.0-RC3"
testImplementation "org.scalatest:scalatest_${scalaBinaryVersion}:3.2.15"
testImplementation "org.scalatestplus:junit-4-13_${scalaBinaryVersion}:3.2.15.0"
}
14 changes: 7 additions & 7 deletions plugin-tester-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
<maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
<pekko.http.cors.version>0.0.0-SNAPSHOT</pekko.http.cors.version>
<pekko.http.version>0.0.0+4456-9a4c0fc7-SNAPSHOT</pekko.http.version>
<grpc.version>1.48.1</grpc.version> <!-- checked synced by VersionSyncCheckPlugin -->
<project.encoding>UTF-8</project.encoding>
</properties>
Expand All @@ -26,11 +26,11 @@
<name>Apache Snapshots Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>
<!-- TODO Remove when proper release of pekko-http-cors is made -->
<!-- TODO remove this resolver when we start using released Pekko jars -->
<repository>
<id>sonatype-snapshots</id>
<name>Sonatype Snapshots Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<id>apache-staging</id>
<name>Apache Staging Repository</name>
<url>https://repository.apache.org/content/groups/staging/</url>
</repository>
</repositories>

Expand All @@ -41,9 +41,9 @@
<version>${pekko.grpc.project.version}</version>
</dependency>
<dependency>
<groupId>ch.megard</groupId>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-http-cors_2.12</artifactId>
<version>${pekko.http.cors.version}</version>
<version>${pekko.http.version}</version>
</dependency>

<!-- Needed for the generated client -->
Expand Down
7 changes: 3 additions & 4 deletions plugin-tester-scala/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ pekkoGrpc {

repositories {
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } // TODO Remove when proper release of pekko-http-cors is made
maven { url 'https://repository.apache.org/content/groups/staging/' } // TODO remove this resolver when we start using released Pekko jars
}

def scalaFullVersion = "2.12.18"
def scalaVersion = org.gradle.util.VersionNumber.parse(scalaFullVersion)
def scalaBinaryVersion = "${scalaVersion.major}.${scalaVersion.minor}"

dependencies {
implementation group: 'ch.megard', name: "pekko-http-cors_${scalaBinaryVersion}", version: '0.0.0-SNAPSHOT'
implementation group: 'org.apache.pekko', name: "pekko-http-cors_${scalaBinaryVersion}", version: '0.0.0+4456-9a4c0fc7-SNAPSHOT'
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
testImplementation "org.apache.pekko:pekko-stream-testkit_${scalaBinaryVersion}:0.0.0+26669-ec5b6764-SNAPSHOT"
testImplementation "org.apache.pekko:pekko-stream-testkit_${scalaBinaryVersion}:1.0.0-RC3"
testImplementation "org.scalatest:scalatest_${scalaBinaryVersion}:3.2.15"
testImplementation "org.scalatestplus:junit-4-13_${scalaBinaryVersion}:3.2.15.0"
}

16 changes: 8 additions & 8 deletions plugin-tester-scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<pekko.version>0.0.0+26669-ec5b6764-SNAPSHOT</pekko.version>
<pekko.http.cors.version>0.0.0-SNAPSHOT</pekko.http.cors.version>
<pekko.version>1.0.0-RC3</pekko.version>
<pekko.http.version>0.0.0+4456-9a4c0fc7-SNAPSHOT</pekko.http.version>
<grpc.version>1.48.1</grpc.version> <!-- checked synced by VersionSyncCheckPlugin -->
<project.encoding>UTF-8</project.encoding>
</properties>
Expand All @@ -25,11 +25,11 @@
<name>Apache Snapshots Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>
<!-- TODO Remove when proper release of pekko-http-cors is made -->
<!-- TODO remove this resolver when we start using released Pekko jars -->
<repository>
<id>sonatype-snapshots</id>
<name>Sonatype Snapshots Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<id>apache-staging</id>
<name>Apache Staging Repository</name>
<url>https://repository.apache.org/content/groups/staging/</url>
</repository>
</repositories>

Expand All @@ -40,9 +40,9 @@
<version>${pekko.grpc.project.version}</version>
</dependency>
<dependency>
<groupId>ch.megard</groupId>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-http-cors_2.12</artifactId>
<version>${pekko.http.cors.version}</version>
<version>${pekko.http.version}</version>
</dependency>

<dependency>
Expand Down
15 changes: 5 additions & 10 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ object Dependencies {
// We don't force Pekko updates because downstream projects can upgrade
// themselves. For more information see
// https://pekko.apache.org//docs/pekko/current/project/downstream-upgrade-strategy.html
val pekko = "0.0.0+26669-ec5b6764-SNAPSHOT"
val pekko = "1.0.0-RC3"
val pekkoBinary = "current"
val pekkoHttp = "0.0.0+4411-6fe04045-SNAPSHOT"
val pekkoHttp = "0.0.0+4456-9a4c0fc7-SNAPSHOT"
val pekkoHttpBinary = "current"

val grpc = "1.48.1" // checked synced by VersionSyncCheckPlugin
Expand All @@ -46,11 +46,10 @@ object Dependencies {
val pekkoStream = "org.apache.pekko" %% "pekko-stream" % Versions.pekko
val pekkoHttp = "org.apache.pekko" %% "pekko-http" % Versions.pekkoHttp
val pekkoHttpCore = "org.apache.pekko" %% "pekko-http-core" % Versions.pekkoHttp
val pekkoHttpCors = "org.apache.pekko" %% "pekko-http-cors" % Versions.pekkoHttp
val pekkoDiscovery = "org.apache.pekko" %% "pekko-discovery" % Versions.pekko
val pekkoSlf4j = "org.apache.pekko" %% "pekko-slf4j" % Versions.pekko

val pekkoHttpCors = "ch.megard" %% "pekko-http-cors" % "0.0.0-SNAPSHOT" // Apache v2

val scalapbCompilerPlugin = "com.thesamet.scalapb" %% "compilerplugin" % scalapb.compiler.Version.scalapbVersion
val scalapbRuntime = ("com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion)
.exclude("io.grpc", "grpc-netty")
Expand Down Expand Up @@ -115,9 +114,7 @@ object Dependencies {
Compile.pekkoHttpCore,
Compile.pekkoHttp,
Compile.pekkoDiscovery,
// TODO Remove exclusion rule when proper release of pekko-http-cors is made
(Compile.pekkoHttpCors % "provided").excludeAll(
"org.apache.pekko" %% "pekko-http"),
Compile.pekkoHttpCors,
Compile.pekkoHttp % "provided",
Test.pekkoTestkit,
Test.pekkoStreamTestkit,
Expand Down Expand Up @@ -151,9 +148,7 @@ object Dependencies {
val pluginTester = l ++= Seq(
// usually automatically added by `suggestedDependencies`, which doesn't work with ReflectiveCodeGen
Compile.grpcStub,
// TODO Remove exclusion rule when proper release of pekko-http-cors is made
Compile.pekkoHttpCors.excludeAll(
"org.apache.pekko" %% "pekko-http"),
Compile.pekkoHttpCors,
Compile.pekkoHttp,
Test.scalaTest,
Test.scalaTestPlusJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import pekko.NotUsed
import pekko.actor.ClassicActorSystemProvider
import pekko.annotation.ApiMayChange
import pekko.grpc.javadsl.ServiceHandler.{ concatOrNotFound, unsupportedMediaType }
import pekko.http.cors.javadsl.settings.CorsSettings
import pekko.http.cors.javadsl.CorsDirectives
import pekko.http.javadsl.marshalling.Marshaller
import pekko.http.javadsl.model.{ HttpRequest, HttpResponse }
import pekko.http.javadsl.server.Route
Expand All @@ -32,8 +34,6 @@ import pekko.japi.function.{ Function => JFunction }
import pekko.stream.Materializer
import pekko.stream.javadsl.{ Keep, Sink, Source }
import pekko.util.ConstantFun
import ch.megard.pekko.http.cors.javadsl.settings.CorsSettings
import ch.megard.pekko.http.cors.javadsl.CorsDirectives

@ApiMayChange
object WebHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import scala.concurrent.Future
import org.apache.pekko
import pekko.actor.ClassicActorSystemProvider
import pekko.annotation.ApiMayChange
import pekko.http.cors.scaladsl.CorsDirectives.cors
import pekko.http.cors.scaladsl.model.HttpHeaderRange
import pekko.http.cors.scaladsl.settings.CorsSettings
import pekko.http.javadsl.{ model => jmodel }
import pekko.http.scaladsl.model.{ HttpMethods, HttpRequest, HttpResponse }
import pekko.http.scaladsl.model.headers._
import pekko.http.scaladsl.server.Route
import pekko.http.scaladsl.server.directives.MarshallingDirectives.handleWith
import ch.megard.pekko.http.cors.scaladsl.CorsDirectives.cors
import ch.megard.pekko.http.cors.scaladsl.model.HttpHeaderRange
import ch.megard.pekko.http.cors.scaladsl.settings.CorsSettings

@ApiMayChange
object WebHandler {
Expand Down

0 comments on commit 74fa607

Please sign in to comment.