This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-pekko-http-quickstart-scala.g8.git
The following commit(s) were added to refs/heads/main by this push:
new 119ed38 change over to pekko
119ed38 is described below
commit 119ed38c574f5f5b00064a397c490939099cf1f3
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Dec 4 17:20:31 2023 +0100
change over to pekko
---
.github/workflows/ci.yml | 19 ++----------
DISCLAIMER | 10 +++++++
README.md | 22 +++++++-------
build.sbt | 9 ++++--
docs/build.sbt | 4 +--
docs/src/main/paradox/backend-actor.md | 6 ++--
docs/src/main/paradox/http-server.md | 6 ++--
docs/src/main/paradox/index.md | 35 +++++++++++-----------
docs/src/main/paradox/intellij-idea.md | 6 ++--
docs/src/main/paradox/json.md | 6 ++--
docs/src/main/paradox/running-the-application.md | 2 +-
docs/src/main/paradox/testing-routes.md | 22 +++++++-------
project/build.properties | 2 +-
project/paradox.sbt | 11 +++++--
project/project-info.conf | 3 ++
src/main/g8/README.md | 6 ++--
src/main/g8/build.sbt | 22 +++++++-------
src/main/g8/default.properties | 8 ++---
src/main/g8/src/main/resources/logback.xml | 4 +--
.../src/main/scala/$package$/QuickstartApp.scala | 13 ++++----
.../g8/src/main/scala/$package$/UserRegistry.scala | 7 +++--
.../g8/src/main/scala/$package$/UserRoutes.scala | 17 ++++++-----
.../src/test/scala/$package$/UserRoutesSpec.scala | 17 ++++++-----
23 files changed, 134 insertions(+), 123 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 67152be..ccd08ee 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,12 +8,12 @@ on:
jobs:
build-test:
- if: github.repository == 'akka/akka-http-quickstart-scala.g8'
+ if: github.repository == 'apache/incubator-pekko-http-quickstart-scala.g8'
runs-on: ubuntu-20.04
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Set up JDK 17
uses: coursier/[email protected]
@@ -29,18 +29,3 @@ jobs:
- name: generate and test, Scala 3
run: |-
sbt new file://$PWD --name=hello-world --scala_version=3.3.1 --force
&& pushd hello-world && sbt test
-
- - name: Email on failure
- if: ${{ failure() }}
- uses: dawidd6/action-send-mail@v3
- with:
- server_address: smtp.gmail.com
- server_port: 465
- username: ${{ secrets.MAIL_USERNAME }}
- password: ${{ secrets.MAIL_PASSWORD }}
- subject: "Failed: ${{ github.workflow }} / ${{ github.job }}"
- to: [email protected]
- from: Akka CI (GHActions)
- body: |
- Job ${{ github.job }} in workflow ${{ github.workflow }} of
${{github.repository}} failed!
-
https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
diff --git a/DISCLAIMER b/DISCLAIMER
new file mode 100644
index 0000000..6a31e0f
--- /dev/null
+++ b/DISCLAIMER
@@ -0,0 +1,10 @@
+Apache Pekko (incubating) is an effort undergoing incubation at the Apache
+Software Foundation (ASF), sponsored by the Apache Incubator PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be
+fully endorsed by the ASF.
diff --git a/README.md b/README.md
index 8f64257..349dcfb 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,32 @@
-## Akka HTTP quickstart in Scala
+## Apache Pekko HTTP quickstart in Scala
-Please see the [quickstart
guide](https://developer.lightbend.com/guides/akka-http-quickstart-scala/) for a
-walk through the code.
-
-You can use [Giter8][g8] to create your own project from the quickstart. Or,
download and extract the zip
file(https://example.lightbend.com/v1/download/akka-quickstart-scala?name=akka-quickstart-scala)
to a convenient location.
+You can use [Giter8][g8] to create your own project from the quickstart.
Prerequisites:
-- JDK 17
+- JDK 11
- sbt 1.4.x or higher
Open a console and run the following command to apply this template:
```
-sbt new akka/akka-http-quickstart-scala.g8
+sbt new apache/incubabor-pekko-http-quickstart-scala.g8
+ ```
+
+You can also install [Giter8](http://www.foundweekends.org/giter8/setup.html)
and install using:
+ ```
+g8 apache/incubabor-pekko-http-quickstart-scala.g8
```
This template will prompt for the following parameters. Press `Enter` if the
default values suit you:
- `name`: Becomes the name of the project.
- `scala_version`: Specifies the Scala version for this project.
-- `akka_http_version`: Specifies which version of Akka HTTP should be used for
this project. Must be at least 10.6.0.
-- `akka_version`: Specifies which version of Akka should be used for this
project. Must be at least 2.9.0.
+- `pekko_http_version`: Specifies which version of Pekko HTTP should be used
for this project.
+- `pekko_version`: Specifies which version of Pekko should be used for this
project.
- `organization`: Specifies the organization for this project.
The template comes with the following sources:
* `QuickstartApp.scala` -- contains the main method which bootstraps the
application
-* `UserRoutes.scala` -- Akka HTTP `routes` defining exposed endpoints
+* `UserRoutes.scala` -- Pekko HTTP `routes` defining exposed endpoints
* `UserRegistry.scala` -- the actor which handles the registration requests
* `JsonFormats.scala` -- converts the JSON data from requests into Scala types
and from Scala types into JSON responses
diff --git a/build.sbt b/build.sbt
index 3649250..43ae8a0 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,3 +1,5 @@
+import org.apache.pekko.PekkoParadoxPlugin.autoImport._
+
// This build is for this Giter8 template.
// To test the template run `g8` or `g8Test` from the sbt session.
// See http://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin
for more details.
@@ -5,7 +7,7 @@ lazy val root = project
.in(file("."))
.enablePlugins(ScriptedPlugin)
.settings(
- name := "akka-http-scala-seed.g8",
+ name := "incubator-pekko-http-scala-seed.g8",
Test / test := {
val _ = (Test / g8Test).toTask("").value
},
@@ -18,7 +20,8 @@ lazy val root = project
// open docs/target/paradox/site/main/index.html
lazy val docs = project
.in(file("docs"))
- .enablePlugins(ParadoxPlugin)
+ .enablePlugins(ParadoxPlugin, PekkoParadoxPlugin)
.settings(
- resolvers += Resolver.typesafeIvyRepo("releases")
+ resolvers += Resolver.typesafeIvyRepo("releases"),
+ pekkoParadoxGithub :=
Some("https://github.com/apache/incubator-pekko-http-quickstart.g8")
)
diff --git a/docs/build.sbt b/docs/build.sbt
index a8b0ef3..339fe82 100644
--- a/docs/build.sbt
+++ b/docs/build.sbt
@@ -5,6 +5,6 @@ Compile / paradoxProperties ++= Map(
"snip.g8root.base_dir" -> "../../../../src/main/g8",
"snip.g8src.base_dir" -> "../../../../src/main/g8/src/main/",
"snip.g8srctest.base_dir" -> "../../../../src/main/g8/src/test/",
- "extref.akka.base_url" -> "https://doc.akka.io/docs/akka/current/%s",
- "extref.akka.http.base_url" ->
"https://doc.akka.io/docs/akka-http/current/%s"
+ "extref.pekko.base_url" -> "https://pekko.apache.org/docs/pekko/current/%s",
+ "extref.pekko.http.base_url" ->
"https://pekko.apache.org/docs/pekko-http/current/%s"
)
diff --git a/docs/src/main/paradox/backend-actor.md
b/docs/src/main/paradox/backend-actor.md
index ff68c05..1922fa9 100644
--- a/docs/src/main/paradox/backend-actor.md
+++ b/docs/src/main/paradox/backend-actor.md
@@ -4,12 +4,12 @@ Backend Actor logic
In this example, the backend only uses one basic actor. In a real system, we
would have many actors interacting with each other and perhaps, multiple data
stores and microservices.
An interesting side-note to add here is about when using actors in
applications like this adds value over just providing functions that would
return `Future`s.
-In fact, if your logic is stateless and very simple request/reply style, you
may not need to back it with an Actor. Actors do shine however when you need to
keep some form of state and allow various requests to access something in (or
*through*) an Actor. The other stellar feature of actors, that futures would
not handle, is scaling-out onto a cluster very easily, by using @extref[Cluster
Sharding](akka:cluster-sharding.html) or other
@extref[location-transparent](akka:general/remoting.h [...]
+In fact, if your logic is stateless and very simple request/reply style, you
may not need to back it with an Actor. Actors do shine however when you need to
keep some form of state and allow various requests to access something in (or
*through*) an Actor. The other stellar feature of actors, that futures would
not handle, is scaling-out onto a cluster very easily, by using @extref[Cluster
Sharding](pekko:cluster-sharding.html) or other
@extref[location-transparent](pekko:general/remoting [...]
-However, the focus of this tutorial is on how to interact with an Actor
backend from within Akka HTTP -- not on the actor itself, so we'll keep it very
simple.
+However, the focus of this tutorial is on how to interact with an Actor
backend from within Pekko HTTP -- not on the actor itself, so we'll keep it
very simple.
The sample code in the `UserRegistry` is very simple. It keeps registered
users in a `Set`. Once it receives messages it matches them to the defined
cases to determine which action to take:
@@snip [UserRegistry.scala]($g8src$/scala/$package$/UserRegistry.scala) {
#user-registry-actor }
-If you feel you need to brush up on your Akka Actor knowledge, the
@extref[Getting Started Guide](akka:guide/index.html) reviews actor concepts in
the context of a simple Internet of Things (IoT) example.
+If you feel you need to brush up on your Pekko Actor knowledge, the
@extref[Getting Started Guide](pekko:guide/index.html) reviews actor concepts
in the context of a simple Internet of Things (IoT) example.
diff --git a/docs/src/main/paradox/http-server.md
b/docs/src/main/paradox/http-server.md
index 5d4f46a..4710f63 100644
--- a/docs/src/main/paradox/http-server.md
+++ b/docs/src/main/paradox/http-server.md
@@ -13,7 +13,7 @@ compartmentalizing them into groups of routes handling
specific parts of the exp
## Binding endpoints
-Each Akka HTTP `Route` contains one or more
`akka.http.scaladsl.server.Directives`, such as: `path`, `get`, `post`,
`complete`, etc. There is also a @extref[low-level
API](akka.http:scala/http/low-level-server-side-api.html) that allows to
inspect requests and create responses manually. For the user registry service,
the example needs to support the actions listed below. For each, we can
identify a path, the HTTP method, and return value:
+Each Pekko HTTP `Route` contains one or more
`org.apache.pekko.http.scaladsl.server.Directives`, such as: `path`, `get`,
`post`, `complete`, etc. There is also a @extref[low-level
API](pekko.http:scala/http/low-level-server-side-api.html) that allows to
inspect requests and create responses manually. For the user registry service,
the example needs to support the actions listed below. For each, we can
identify a path, the HTTP method, and return value:
| Functionality | HTTP Method | Path | Returns |
|--------------------|-------------|------------|----------------------|
@@ -49,7 +49,7 @@ The following directives are used in the above example:
However this method is slightly more error-prone since forgetting to add
the `~` between routes in subsequent lines
will not result in a compile error (as it would when using the `concat`
directive) resulting in only the "last" route to be returned. <br/>
<br/>
- In short other words: you may see the `~` operator used in Akka HTTP apps,
however it is recommended to use the `concat` directive as safer alternative.
+ In short other words: you may see the `~` operator used in Pekko HTTP
apps, however it is recommended to use the `concat` directive as safer
alternative.
**Retrieving users**
@@ -76,7 +76,7 @@ The following directives are used in the above example:
* `pathPrefix("users")` : the path that is used to match the incoming request
against.
* `concat`: concatenates two or more route alternatives. Routes are attempted
one after another. If a route rejects a request, the next route in the chain is
attempted. This continues until a route in the chain produces a response.
-* `path(Segment) { user =>` : this bit of code matches against URIs of the
exact format `/users/$ID` and the `Segment` is automatically extracted into the
`user` variable so that we can get to the value passed in the URI. For example
`/users/Bruce` will populate the `user` variable with the value "Bruce." There
is plenty of more features available for handling of URIs, see @extref[pattern
matchers](akka.http:scala/http/routing-dsl/path-matchers.html#basic-pathmatchers)
for more information.
+* `path(Segment) { user =>` : this bit of code matches against URIs of the
exact format `/users/$ID` and the `Segment` is automatically extracted into the
`user` variable so that we can get to the value passed in the URI. For example
`/users/Bruce` will populate the `user` variable with the value "Bruce." There
is plenty of more features available for handling of URIs, see @extref[pattern
matchers](pekko.http:scala/http/routing-dsl/path-matchers.html#basic-pathmatchers)
for more information.
**Retrieving a user**
diff --git a/docs/src/main/paradox/index.md b/docs/src/main/paradox/index.md
index 67f48a8..a933b37 100644
--- a/docs/src/main/paradox/index.md
+++ b/docs/src/main/paradox/index.md
@@ -1,13 +1,12 @@
-Akka HTTP Quickstart for Scala
-==============================
+# Apache Pekko HTTP Quickstart for Scala
-Akka HTTP offers a general toolkit for providing and consuming HTTP-based
services. The Akka HTTP modules implement a full server- and client-side HTTP
stack on top of `akka-actor` and `akka-stream`. A typical application does not
sit on top of Akka HTTP. Instead, Akka HTTP makes it easier to build
integration layers based on HTTP, and therefore stays on the sidelines. This
allows you to base your app on what makes sense and use Akka HTTP for HTTP
integration.
+Pekko HTTP offers a general toolkit for providing and consuming HTTP-based
services. The Pekko HTTP modules implement a full server- and client-side HTTP
stack on top of `pekko-actor` and `pekko-stream`. A typical application does
not sit on top of Pekko HTTP. Instead, Pekko HTTP makes it easier to build
integration layers based on HTTP, and therefore stays on the sidelines. This
allows you to base your app on what makes sense and use Pekko HTTP for HTTP
integration.
-Akka HTTP is not a framework--not because we don't like frameworks--but to
provide maximum flexibility. For example, you might use the Play framework to
implement browser-based interactions or Lagom framework for creating
microservices, both of them are also based on Akka.
+Pekko HTTP is not a framework--not because we don't like frameworks--but to
provide maximum flexibility. For example, you might use the Play framework to
implement browser-based interactions or Lagom framework for creating
microservices, both of them are also based on Pekko.
-Akka HTTP follows a rather open design and often offers several APIs for
accomplishing the same thing. You can choose the API with the level of
abstraction that best suits your application. If you have trouble achieving
something using a high-level API, you can probably find a lower-level API to
use. The low-level APIs offer more flexibility, but might require you to write
more application code.
+Pekko HTTP follows a rather open design and often offers several APIs for
accomplishing the same thing. You can choose the API with the level of
abstraction that best suits your application. If you have trouble achieving
something using a high-level API, you can probably find a lower-level API to
use. The low-level APIs offer more flexibility, but might require you to write
more application code.
-This guide highlights Akka HTTP fundamentals in the context of a simple user
registry [REST
service](https://en.wikipedia.org/wiki/Representational_state_transfer). Within
30 minutes, you should be able to:
+This guide highlights Pekko HTTP fundamentals in the context of a simple user
registry [REST
service](https://en.wikipedia.org/wiki/Representational_state_transfer). Within
30 minutes, you should be able to:
* Download the quickstart project and run the app.
* Follow this guide to explore the code.
@@ -15,18 +14,18 @@ This guide highlights Akka HTTP fundamentals in the context
of a simple user reg
## Prerequisite
-Having a basic understanding of Akka actors will make it easier to understand
the example. If you are new to Akka, we recommend completing the [Akka
Quickstart](https://developer.lightbend.com/guides/akka-quickstart-scala/)
guide before this tutorial.
+Having a basic understanding of Pekko actors will make it easier to understand
the example. If you are new to Pekko, we recommend completing the [Pekko
Quickstart](https://developer.lightbend.com/guides/pekko-quickstart-scala/)
guide before this tutorial.
-You can run the Akka HTTP example project on Linux, MacOS, or Windows. The
only prerequisite is Java 8.
+You can run the Pekko HTTP example project on Linux, MacOS, or Windows. The
only prerequisite is Java 8.
## Downloading the example
-The Akka HTTP example for Scala is a zipped project that includes a
distribution of the [sbt](http://www.scala-sbt.org) build tool. Download and
unzip the example as follows:
+The Pekko HTTP example for Scala is a zipped project that includes a
distribution of the [sbt](http://www.scala-sbt.org) build tool. Download and
unzip the example as follows:
-1. Download the project [zip
file](https://example.lightbend.com/v1/download/akka-http-quickstart-scala?name=akka-http-quickstart-scala).
+1. Download the project [zip
file](https://example.lightbend.com/v1/download/pekko-http-quickstart-scala?name=pekko-http-quickstart-scala).
2. Extract the zip file to a convenient location:
-* On Linux and MacOS systems, open a terminal and use the command `unzip`
akka-quickstart-scala.zip. Note: On OSX, if you unzip using Archiver, you also
have to make the sbt files executable by entering the following two commands:
+* On Linux and MacOS systems, open a terminal and use the command `unzip`
pekko-quickstart-scala.zip. Note: On OSX, if you unzip using Archiver, you also
have to make the sbt files executable by entering the following two commands:
```
$ chmod u+x ./sbt
@@ -41,7 +40,7 @@ To run Hello World:
In a console, change directories to the top level of the unzipped project.
-For example, if you used the default project name,
`akka-http-quickstart-scala`, and extracted the project to your root directory,
from the root directory, enter: `cd akka-http-quickstart-scala`
+For example, if you used the default project name,
`pekko-http-quickstart-scala`, and extracted the project to your root
directory, from the root directory, enter: `cd pekko-http-quickstart-scala`
Start sbt:
@@ -52,7 +51,7 @@ When you run sbt, it downloads project dependencies. The `>`
prompt indicates th
At the sbt prompt, enter `reStart`.
-sbt builds the project, starts an Akka HTTP server, and runs the example
application.
+sbt builds the project, starts a Pekko HTTP server, and runs the example
application.
The output should look something like this:
@@ -60,17 +59,17 @@ The output should look something like this:
[info] Loading global plugins from /Users/x/.sbt/0.13/plugins
...
[info] Running com.example.QuickstartServer
-[2019-10-24 15:26:39,182] [INFO] [HelloAkkaHttpServer]
[HelloAkkaHttpServer-akka.actor.default-dispatcher-3]
[akka://HelloAkkaHttpServer/user/HttpServer] - Server online at
http://127.0.0.1:8080/
+[2019-10-24 15:26:39,182] [INFO] [HelloPekkoHttpServer]
[HelloPekkoHttpServer-pekko.actor.default-dispatcher-3]
[pekko://HelloPekkoHttpServer/user/HttpServer] - Server online at
http://127.0.0.1:8080/
```
-The Akka HTTP server is now running, and you can test it by sending simple
HTTP requests.
+The Pekko HTTP server is now running, and you can test it by sending simple
HTTP requests.
You can restart it by entering `reStart` again, and stop it with `reStop`.
To restart your application each time a change is detected, run `~reStart`.
## Example app overview
-The user registry example contains functionality for adding, retrieving, or
deleting a single user and for retrieving all users. Akka HTTP provides a
[domain-specific
language](https://en.wikipedia.org/wiki/Domain-specific_language) (DSL) to
simplify the definition of endpoints as a `Route`. In this example, a `Route`
defines: the paths `/users` and `/user`, the available HTTP methods, and when
applicable, parameters or payloads.
+The user registry example contains functionality for adding, retrieving, or
deleting a single user and for retrieving all users. Pekko HTTP provides a
[domain-specific
language](https://en.wikipedia.org/wiki/Domain-specific_language) (DSL) to
simplify the definition of endpoints as a `Route`. In this example, a `Route`
defines: the paths `/users` and `/user`, the available HTTP methods, and when
applicable, parameters or payloads.
When the example app starts up, it creates an ActorSystem with a
`UserRegistry` Actor and binds the defined routes to a port, in this case,
`localhost:8080`. When the endpoints are invoked, they interact with the
`UserRegistry` Actor, which contains the business logic. The diagram below
illustrates runtime behavior, where that the HTTP server receives for the
defined `route` endpoints, which are handled by the `UserRegistry` actor:
@@ -173,12 +172,12 @@ The system should respond with a list of users in JSON
format.
## Learning from the example
-Congratulations, you just ran and exercised your first Akka HTTP app! You got
a preview of how routes make it easy to communicate over HTTP.
+Congratulations, you just ran and exercised your first Pekko HTTP app! You got
a preview of how routes make it easy to communicate over HTTP.
The example is implemented in the following four source files:
* `QuickstartApp.scala` -- contains the main method which bootstraps the
application
-* `UserRoutes.scala` -- Akka HTTP `routes` defining exposed endpoints
+* `UserRoutes.scala` -- Pekko HTTP `routes` defining exposed endpoints
* `UserRegistry.scala` -- the actor which handles the registration requests
* `JsonFormats.scala` -- converts the JSON data from requests into Scala types
and from Scala types into JSON responses
diff --git a/docs/src/main/paradox/intellij-idea.md
b/docs/src/main/paradox/intellij-idea.md
index 57faa4f..46bae87 100644
--- a/docs/src/main/paradox/intellij-idea.md
+++ b/docs/src/main/paradox/intellij-idea.md
@@ -1,11 +1,11 @@
IntelliJ IDEA
-------------
-[IntelliJ IDEA](https://www.jetbrains.com/idea/) from JetBrains is one of the
leading IDEs in the Java/Scala community, and it has excellent support for Akka
HTTP. This section of the tutorial describes how to set up, test and run the
sample project in IntelliJ.
+[IntelliJ IDEA](https://www.jetbrains.com/idea/) from JetBrains is one of the
leading IDEs in the Java/Scala community, and it has excellent support for
Pekko HTTP. This section of the tutorial describes how to set up, test and run
the sample project in IntelliJ.
## Setting up the project
-To add the Akka HTTP example project to IntelliJ, follow these steps:
+To add the Pekko HTTP example project to IntelliJ, follow these steps:
1. Open IntelliJ.
1. Select **Open** from the Welcome dialog or **File > Open** from the
Editor.
@@ -33,4 +33,4 @@ In the **Project** pane, right click the `QuickstartApp`
source file. Select **R
## Tutorial done!
-Congratulations! You can start building real-world applications that use Akka
HTTP. Of course, we didn't have time to cover all Akka HTTP features in this
short guide. See the @extref[documentation](akka.http:scala/http/index.html) to
learn more.
+Congratulations! You can start building real-world applications that use Pekko
HTTP. Of course, we didn't have time to cover all Pekko HTTP features in this
short guide. See the @extref[documentation](pekko.http:scala/http/index.html)
to learn more.
diff --git a/docs/src/main/paradox/json.md b/docs/src/main/paradox/json.md
index 1281d47..bfcc4a4 100644
--- a/docs/src/main/paradox/json.md
+++ b/docs/src/main/paradox/json.md
@@ -26,13 +26,13 @@ we want to use them:
@@@ note
-While we used Spray JSON in this example, various other libraries are
supported via the [Akka HTTP
JSON](https://github.com/hseeberger/akka-http-json)
+While we used Spray JSON in this example, various other libraries are
supported via the [Pekko HTTP
JSON](https://github.com/pjfanning/pekko-http-json)
project, including [Jackson](https://github.com/FasterXML/jackson), [Play
JSON](https://www.playframework.com/documentation/2.6.x/ScalaJson)
or [circe](https://circe.github.io/circe/).
-Each library comes with different trade-offs in performance and
user-friendlieness. Spray JSON is generally the fastest, though it requires you
to write the format values explicitly. If you'd rather make "everything"
automatically marshallable into JSON values you might want to use Jackson or
Circe instead.
+Each library comes with different trade-offs in performance and
user-friendliness. Spray JSON is generally the fastest, though it requires you
to write the format values explicitly. If you'd rather make "everything"
automatically marshallable into JSON values you might want to use Jackson or
Circe instead.
-If you're not sure, we recommend sticking to Spray JSON as it's the closest in
philosophy to Akka HTTP - being explicit about all capabilities.
+If you're not sure, we recommend sticking to Spray JSON as it's the closest in
philosophy to Pekko HTTP - being explicit about all capabilities.
@@@
diff --git a/docs/src/main/paradox/running-the-application.md
b/docs/src/main/paradox/running-the-application.md
index 7e57c94..f2ef1af 100644
--- a/docs/src/main/paradox/running-the-application.md
+++ b/docs/src/main/paradox/running-the-application.md
@@ -9,7 +9,7 @@ When you ran the example for the first time, you were able to
create and retriev
To test this functionality, follow these steps. If you need reminders on
starting the app or sending requests, refer to the
@ref:[instructions](index.md#exercising-the-example) in the beginning.
-`1.` If the Akka HTTP server is still running, stop and restart it.
+`1.` If the Pekko HTTP server is still running, stop and restart it.
`2.` With no users registered, use your tool of choice to:
`3.` Retrieve a list of users. Hint: use the `GET` method and append `/users`
to the URL.
diff --git a/docs/src/main/paradox/testing-routes.md
b/docs/src/main/paradox/testing-routes.md
index 46417d2..c3c1af2 100644
--- a/docs/src/main/paradox/testing-routes.md
+++ b/docs/src/main/paradox/testing-routes.md
@@ -13,13 +13,13 @@ to cover all our routes, without having to bring up the
entire application.
There are multiple ways one can test an HTTP application of course, however
lets start at the simplest and also quickest
way: unit testing. In this style of testing, we won't even need to spin up an
actual server - all the tests will be
-executed on the routes directly - without the need of hitting actual network.
This is due to Akka HTTP's pure design
+executed on the routes directly - without the need of hitting actual network.
This is due to Pekko HTTP's pure design
and separation between the network layer (represented as a bi-directional
`Flow` of byte strings to Http domain objects).
-In other words, unit testing in Akka HTTP is simply "executing" the routes by
passing in an `HttpResponse` to the route,
+In other words, unit testing in Pekko HTTP is simply "executing" the routes by
passing in an `HttpResponse` to the route,
and later inspecting what `HttpResponse` (or `rejection` if the request could
not be handled) it resulted in. All this
in-memory, without having to start a real HTTP server - which gives us supreme
speed and turn-over time when developing
-an application using Akka.
+an application using Pekko.
First we'll need to extend a number of base traits:
@@ -27,7 +27,7 @@ First we'll need to extend a number of base traits:
Here we're using ScalaTest which provides the testing *style* `WordSpec` and
the `Matchers` trait which provides
the `something should === (somethingElse)` syntax [and
more](http://www.scalatest.org/user_guide/using_matchers).
-Next we inherit the Akka HTTP provided `ScalatestRouteTest` bridge trait that
provides Route specific testing facilities,
+Next we inherit the Pekko HTTP provided `ScalatestRouteTest` bridge trait that
provides Route specific testing facilities,
and binds into ScalaTest's lifecycle methods such that the `ActorSystem` is
started and stopped automatically for us.
@@ -40,15 +40,15 @@ If you're using Specs2 instead, you can simply extend the
`Specs2RouteTest` supp
Next we'll need to bring into the test class our routes that we want to test.
We're doing this by creating an instance of the `UserRoutes` and importing the
marshallers from `JsonFormats` into scope for the tests to use, as well as
makes it possible to implement all abstract members of that trait in the test
itself - all in in a fully type-safe way.
-We'll want to use the Akka `ActorTestKit` however the `ScalaRouteTest` only
knows of the "classic" `ActorSystem` so we need
+We'll want to use the Pekko `ActorTestKit` however the `ScalaRouteTest` only
knows of the "classic" `ActorSystem` so we need
to provide a small adapter allowing us to combine both.
-Next we need to have a `ActorRef[UserRegistry.Command]` available that that
our routes will interact with. We are using the actual actor since it does not
have any dependencies, this makes the test more like an integration test than a
unit test. For a more isolated test a `TestProbe` from the Akka Testkit could
be used - it would allow us to verify the route indeed did send a message do
the Actor or not and send specific responses back in each test case.
+Next we need to have a `ActorRef[UserRegistry.Command]` available that that
our routes will interact with. We are using the actual actor since it does not
have any dependencies, this makes the test more like an integration test than a
unit test. For a more isolated test a `TestProbe` from the Pekko Testkit could
be used - it would allow us to verify the route indeed did send a message do
the Actor or not and send specific responses back in each test case.
@@snip
[QuickstartServer.scala]($g8srctest$/scala/$package$/UserRoutesSpec.scala) {
#set-up }
We could create an actor that replies with a mocked response here instead if
we wanted to, this is especially useful if
-the route awaits an response from the actor before rendering the
`HttpResponse` to the client. Read about the @extref[Akka
TestKit](akka:testing.html) and it's utilities like `TestProbe` if this is
something you'd like to learn more about.
+the route awaits an response from the actor before rendering the
`HttpResponse` to the client. Read about the @extref[Pekko
TestKit](pekko:testing.html) and it's utilities like `TestProbe` if this is
something you'd like to learn more about.
Let's write our first test, in which we'll hit the `/users` endpoint with a
`GET` request:
@@ -59,11 +59,11 @@ We simply construct a raw `HttpRequest` object and pass it
into the route using
After all, the route is a function of `HttpRequest => Future[HttpResponse]` -
here we don't need to explicitly write code
that's awaiting on the response, it's handled for us.
-Inside the check block we can inspect @extref[all kinds of
attributes](akka.http:routing-dsl/testkit.html#table-of-inspectors) of the
received response, like `status`, `contentType` and
+Inside the check block we can inspect @extref[all kinds of
attributes](pekko.http:routing-dsl/testkit.html#table-of-inspectors) of the
received response, like `status`, `contentType` and
of course the full response which we can easily convert to a string for
testing using `responseAs[String]`. This infrastructure
is using the same marshalling infrastructure as our routes, so if the response
was a `User` JSON, we could say `responseAs[User]` and write our assertions on
the actual object.
-In the next test we'd like test a `POST` endpoint, so we need to send an
entity to the endpoint in order to create a new `User`. This time, instead of
using the raw `HttpRequest` to build the request we'll use a small DSL provided
by the Akka HTTP. The DSL allows you to write `Post("/hello)` instead of having
to declare the full thing in the raw API (which would have been:
`HttpRequest(method = HttpMethods.POST, uri = "/hello")`), and next we'll add
the User JSON into the request body:
+In the next test we'd like test a `POST` endpoint, so we need to send an
entity to the endpoint in order to create a new `User`. This time, instead of
using the raw `HttpRequest` to build the request we'll use a small DSL provided
by the Pekko HTTP. The DSL allows you to write `Post("/hello)` instead of
having to declare the full thing in the raw API (which would have been:
`HttpRequest(method = HttpMethods.POST, uri = "/hello")`), and next we'll add
the User JSON into the request body:
@@snip
[QuickstartServer.scala]($g8srctest$/scala/$package$/UserRoutesSpec.scala) {
#testing-post }
@@ -74,7 +74,7 @@ why it's so convenient to extend the Routes trait when
testing it - everything t
our disposal when writing the test.
This concludes the basics of unit testing HTTP routes, to learn more please
refer to the
-[Akka HTTP TestKit documentation]().
+[Pekko HTTP TestKit documentation]().
### Complete unit test code listing
@@ -96,7 +96,7 @@ Sometimes however one wants to test the complete "full
application", including s
Some network specific features like timeouts, behaviour of entities
(streamed directly from the network, instead of
in memory objects like in the unit testing style) may behave differently in
the unit-testing style showcased above.
- If you want to test specific timing and entity draining behaviours of your
apps you may want to add full integration tests for them. For most routes this
should not be needed, however we'd recommend doing so when using more of the
streaming features of Akka HTTP.
+ If you want to test specific timing and entity draining behaviours of your
apps you may want to add full integration tests for them. For most routes this
should not be needed, however we'd recommend doing so when using more of the
streaming features of Pekko HTTP.
@@@
diff --git a/project/build.properties b/project/build.properties
index 2743082..e8a1e24 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version=1.9.6
+sbt.version=1.9.7
diff --git a/project/paradox.sbt b/project/paradox.sbt
index 3e62e80..4f96752 100644
--- a/project/paradox.sbt
+++ b/project/paradox.sbt
@@ -1,2 +1,9 @@
-// sbt-paradox, used for documentation
-addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.5")
+// We have to deliberately use older versions of sbt-paradox because current
Pekko sbt build
+// only loads on JDK 1.8 so we need to bring in older versions of parboiled
which support JDK 1.8
+addSbtPlugin(("org.apache.pekko" % "pekko-sbt-paradox" % "1.0.0").excludeAll(
+ "com.lightbend.paradox", "sbt-paradox",
+ "com.lightbend.paradox" % "sbt-paradox-apidoc",
+ "com.lightbend.paradox" % "sbt-paradox-project-info"))
+addSbtPlugin(("com.lightbend.paradox" % "sbt-paradox" % "0.9.2").force())
+addSbtPlugin(("com.lightbend.paradox" % "sbt-paradox-apidoc" %
"0.10.1").force())
+addSbtPlugin(("com.lightbend.paradox" % "sbt-paradox-project-info" %
"2.0.0").force())
diff --git a/project/project-info.conf b/project/project-info.conf
new file mode 100644
index 0000000..e365342
--- /dev/null
+++ b/project/project-info.conf
@@ -0,0 +1,3 @@
+project-info {
+
+}
diff --git a/src/main/g8/README.md b/src/main/g8/README.md
index 2fd4715..396da2c 100644
--- a/src/main/g8/README.md
+++ b/src/main/g8/README.md
@@ -1,11 +1,11 @@
-# Sample Akka HTTP server
+# Sample Pekko HTTP server
-This is a sample Akka HTTP endpoint keeping an in-memory database of users
that can be created and listed.
+This is a sample Pekko HTTP endpoint keeping an in-memory database of users
that can be created and listed.
Sources in the sample:
* `QuickstartApp.scala` -- contains the main method which bootstraps the
application
-* `UserRoutes.scala` -- Akka HTTP `routes` defining exposed endpoints
+* `UserRoutes.scala` -- Pekko HTTP `routes` defining exposed endpoints
* `UserRegistry.scala` -- the actor which handles the registration requests
* `JsonFormats.scala` -- converts the JSON data from requests into Scala types
and from Scala types into JSON responses
diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt
index 7db9f98..bdce20f 100644
--- a/src/main/g8/build.sbt
+++ b/src/main/g8/build.sbt
@@ -1,7 +1,5 @@
-lazy val akkaHttpVersion = "$akka_http_version$"
-lazy val akkaVersion = "$akka_version$"
-
-resolvers += "Akka library repository".at("https://repo.akka.io/maven")
+lazy val pekkoHttpVersion = "$pekko_http_version$"
+lazy val pekkoVersion = "$pekko_version$"
// Run in a separate JVM, to make sure sbt waits until all threads have
// finished before returning.
@@ -17,14 +15,14 @@ lazy val root = (project in file(".")).
)),
name := "$name$",
libraryDependencies ++= Seq(
- "com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
- "com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
- "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
- "com.typesafe.akka" %% "akka-stream" % akkaVersion,
- "ch.qos.logback" % "logback-classic" % "1.2.11",
+ "org.apache.pekko" %% "pekko-http" % pekkoHttpVersion,
+ "org.apache.pekko" %% "pekko-http-spray-json" % pekkoHttpVersion,
+ "org.apache.pekko" %% "pekko-actor-typed" % pekkoVersion,
+ "org.apache.pekko" %% "pekko-stream" % pekkoVersion,
+ "ch.qos.logback" % "logback-classic" % "1.2.13",
- "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion %
Test,
- "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion %
Test,
- "org.scalatest" %% "scalatest" % "3.2.12" %
Test
+ "org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpVersion %
Test,
+ "org.apache.pekko" %% "pekko-actor-testkit-typed" % pekkoVersion %
Test,
+ "org.scalatest" %% "scalatest" % "3.2.17" %
Test
)
)
diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties
index a2daf06..1c76915 100644
--- a/src/main/g8/default.properties
+++ b/src/main/g8/default.properties
@@ -1,8 +1,8 @@
-name=My Akka HTTP Project
-description=This is a seed project which creates a basic build for an Akka
HTTP application using Scala.
+name=My Pekko HTTP Project
+description=This is a seed project which creates a basic build for a Pekko
HTTP application using Scala.
scala_version=2.13.12
-akka_http_version=10.6.0
-akka_version=2.9.0
+pekko_http_version=1.0.0
+pekko_version=1.0.2
sbt_version=maven(org.scala-sbt, sbt, stable)
organization=com.example
package=$organization$
diff --git a/src/main/g8/src/main/resources/logback.xml
b/src/main/g8/src/main/resources/logback.xml
index b1fe9ae..915d59b 100644
--- a/src/main/g8/src/main/resources/logback.xml
+++ b/src/main/g8/src/main/resources/logback.xml
@@ -1,9 +1,9 @@
<configuration>
<!-- This is a development logging configuration that logs to standard
out, for an example of a production
- logging config, see the Akka docs:
https://doc.akka.io/docs/akka/2.6/typed/logging.html#logback -->
+ logging config, see the Pekko docs:
https://pekko.apache.org/docs/pekko/current/typed/logging.html#logback -->
<appender name="STDOUT" target="System.out"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
- <pattern>[%date{ISO8601}] [%level] [%logger] [%thread]
[%X{akkaSource}] - %msg%n</pattern>
+ <pattern>[%date{ISO8601}] [%level] [%logger] [%thread]
[%X{pekkoSource}] - %msg%n</pattern>
</encoder>
</appender>
diff --git a/src/main/g8/src/main/scala/$package$/QuickstartApp.scala
b/src/main/g8/src/main/scala/$package$/QuickstartApp.scala
index 4001052..5e7f8e4 100644
--- a/src/main/g8/src/main/scala/$package$/QuickstartApp.scala
+++ b/src/main/g8/src/main/scala/$package$/QuickstartApp.scala
@@ -1,9 +1,10 @@
package $package$
-import akka.actor.typed.ActorSystem
-import akka.actor.typed.scaladsl.Behaviors
-import akka.http.scaladsl.Http
-import akka.http.scaladsl.server.Route
+import org.apache.pekko
+import pekko.actor.typed.ActorSystem
+import pekko.actor.typed.scaladsl.Behaviors
+import pekko.http.scaladsl.Http
+import pekko.http.scaladsl.server.Route
import scala.util.Failure
import scala.util.Success
@@ -12,7 +13,7 @@ import scala.util.Success
object QuickstartApp {
//#start-http-server
private def startHttpServer(routes: Route)(implicit system: ActorSystem[_]):
Unit = {
- // Akka HTTP still needs a classic ActorSystem to start
+ // Pekko HTTP still needs a classic ActorSystem to start
import system.executionContext
val futureBinding = Http().newServerAt("localhost", 8080).bind(routes)
@@ -37,7 +38,7 @@ object QuickstartApp {
Behaviors.empty
}
- val system = ActorSystem[Nothing](rootBehavior, "HelloAkkaHttpServer")
+ val system = ActorSystem[Nothing](rootBehavior, "HelloPekkoHttpServer")
//#server-bootstrapping
}
}
diff --git a/src/main/g8/src/main/scala/$package$/UserRegistry.scala
b/src/main/g8/src/main/scala/$package$/UserRegistry.scala
index e755a42..73dd260 100644
--- a/src/main/g8/src/main/scala/$package$/UserRegistry.scala
+++ b/src/main/g8/src/main/scala/$package$/UserRegistry.scala
@@ -1,9 +1,10 @@
package $package$
//#user-registry-actor
-import akka.actor.typed.ActorRef
-import akka.actor.typed.Behavior
-import akka.actor.typed.scaladsl.Behaviors
+import org.apache.pekko
+import pekko.actor.typed.ActorRef
+import pekko.actor.typed.Behavior
+import pekko.actor.typed.scaladsl.Behaviors
import scala.collection.immutable
//#user-case-classes
diff --git a/src/main/g8/src/main/scala/$package$/UserRoutes.scala
b/src/main/g8/src/main/scala/$package$/UserRoutes.scala
index beefec7..d23657c 100644
--- a/src/main/g8/src/main/scala/$package$/UserRoutes.scala
+++ b/src/main/g8/src/main/scala/$package$/UserRoutes.scala
@@ -1,22 +1,23 @@
package $package$
-import akka.http.scaladsl.server.Directives._
-import akka.http.scaladsl.model.StatusCodes
-import akka.http.scaladsl.server.Route
+import org.apache.pekko
+import pekko.http.scaladsl.server.Directives._
+import pekko.http.scaladsl.model.StatusCodes
+import pekko.http.scaladsl.server.Route
import scala.concurrent.Future
import $package$.UserRegistry._
-import akka.actor.typed.ActorRef
-import akka.actor.typed.ActorSystem
-import akka.actor.typed.scaladsl.AskPattern._
-import akka.util.Timeout
+import pekko.actor.typed.ActorRef
+import pekko.actor.typed.ActorSystem
+import pekko.actor.typed.scaladsl.AskPattern._
+import pekko.util.Timeout
//#import-json-formats
//#user-routes-class
class UserRoutes(userRegistry: ActorRef[UserRegistry.Command])(implicit val
system: ActorSystem[_]) {
//#user-routes-class
- import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+ import pekko.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import JsonFormats._
//#import-json-formats
diff --git a/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala
b/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala
index 5def31d..5c9fa3a 100644
--- a/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala
+++ b/src/main/g8/src/test/scala/$package$/UserRoutesSpec.scala
@@ -2,11 +2,12 @@ package $package$
//#user-routes-spec
//#test-top
-import akka.actor.testkit.typed.scaladsl.ActorTestKit
-import akka.actor.typed.ActorSystem
-import akka.http.scaladsl.marshalling.Marshal
-import akka.http.scaladsl.model._
-import akka.http.scaladsl.testkit.ScalatestRouteTest
+import org.apache.pekko
+import pekko.actor.testkit.typed.scaladsl.ActorTestKit
+import pekko.actor.typed.ActorSystem
+import pekko.http.scaladsl.marshalling.Marshal
+import pekko.http.scaladsl.model._
+import pekko.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
@@ -15,11 +16,11 @@ import org.scalatest.wordspec.AnyWordSpec
class UserRoutesSpec extends AnyWordSpec with Matchers with ScalaFutures with
ScalatestRouteTest {
//#test-top
- // the Akka HTTP route testkit does not yet support a typed actor system
(https://github.com/akka/akka-http/issues/2036)
+ // the Pekko HTTP route testkit does not yet support a typed actor system
(https://github.com/akka/akka-http/issues/2036)
// so we have to adapt for now
lazy val testKit = ActorTestKit()
implicit def typedSystem: ActorSystem[_] = testKit.system
- override def createActorSystem(): akka.actor.ActorSystem =
+ override def createActorSystem(): pekko.actor.ActorSystem =
testKit.system.classicSystem
// Here we need to implement all the abstract members of UserRoutes.
@@ -30,7 +31,7 @@ class UserRoutesSpec extends AnyWordSpec with Matchers with
ScalaFutures with Sc
lazy val routes = new UserRoutes(userRegistry).userRoutes
// use the json formats to marshal and unmarshall objects in the test
- import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+ import pekko.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import JsonFormats._
//#set-up
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]