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-java.g8.git
The following commit(s) were added to refs/heads/main by this push:
new 1ebfe3d switch to pekko
1ebfe3d is described below
commit 1ebfe3d5e803aa8d6ac62221ba41bcb1f60c5886
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Dec 4 20:53:41 2023 +0100
switch to pekko
---
.github/workflows/ci.yml | 4 +-
DISCLAIMER | 10 +++++
README.md | 26 ++++++-----
build.sbt | 7 +--
docs/build.sbt | 4 +-
docs/src/main/paradox/backend-actor.md | 6 +--
docs/src/main/paradox/http-server.md | 4 +-
docs/src/main/paradox/index.md | 43 +++++++-----------
docs/src/main/paradox/intellij-idea.md | 10 ++---
docs/src/main/paradox/json.md | 8 ++--
docs/src/main/paradox/running-the-application.md | 2 +-
docs/src/main/paradox/testing-routes.md | 8 ++--
project/build.properties | 2 +-
project/paradox.sbt | 10 ++++-
project/project-info.conf | 3 ++
src/main/g8/build.gradle | 25 +++++------
src/main/g8/build.sbt | 24 +++++-----
src/main/g8/default.properties | 6 +--
src/main/g8/pom.xml | 52 +++++++++-------------
src/main/g8/project/build.properties | 2 +-
.../g8/src/main/java/$package$/QuickstartApp.java | 30 ++++++-------
.../g8/src/main/java/$package$/UserRegistry.java | 12 ++---
.../g8/src/main/java/$package$/UserRoutes.java | 18 ++++----
src/main/g8/src/main/resources/logback.xml | 4 +-
.../g8/src/test/java/$package$/UserRoutesTest.java | 14 +++---
25 files changed, 166 insertions(+), 168 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 74e6d77..b2abd96 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-java.g8'
+ if: github.repository == 'apache/incubator-pekko-http-quickstart-java.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]
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 fce31ca..b75f769 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,28 @@
-## Akka HTTP quickstart in Java
+## Apache Pekko HTTP quickstart in Java
-Please see the [quickstart
guide](https://developer.lightbend.com/guides/akka-http-quickstart-java/) 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
-- [sbt][sbt] 1.9.6 or higher ([download here][sbt_download])
+- 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-java-seed.g8
+sbt new apache/incubabor-pekko-http-quickstart-java.g8
+ ```
+
+You can also install [Giter8](http://www.foundweekends.org/giter8/setup.html)
and install using:
+ ```
+g8 apache/incubabor-pekko-http-quickstart-java.g8
```
This template will prompt for the following parameters. Press `Enter` if the
default values suit you:
- `name`: Becomes the name of the project.
- `organisation`: Provides an organisation name for the project.
-- `akka-http-version`: Specifies which version of Akka HTTP should be used for
this project.
-- `akka-version`: Specifies which version of Akka should be used for this
project.
+- `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.
-This template comes with example for an Akka HTTP server on Java
`QuickstartServer`, along with their respective tests.
+This template comes with example for an Pekko HTTP server on Java
`QuickstartServer`, along with their respective tests.
Once inside the project folder, to run this code, you can issue the following
command to run the server:
```
@@ -37,7 +39,7 @@ or
```
gradle run
```
-Both commands run `com.lightbend.akka.http.sample.QuickstartServer` by default.
+Both commands run `QuickstartServer` by default.
Template license
diff --git a/build.sbt b/build.sbt
index 90e59e7..283348b 100644
--- a/build.sbt
+++ b/build.sbt
@@ -5,7 +5,7 @@ lazy val root = project
.in(file("."))
.enablePlugins(ScriptedPlugin)
.settings(
- name := "akka-http-java-seed.g8",
+ name := "incubator-pekko-http-java-seed.g8",
Test / test := {
val _ = (Test / g8Test).toTask("").value
},
@@ -18,7 +18,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-java.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 547a447..2184209 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 `CompletionStage`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 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.html) tec [...]
+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 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.html) t [...]
-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.java]($g8src$/java/$package$/UserRegistry.java) {
#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 4c88669..53ea538 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.javadsl.server.Directive`, 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.javadsl.server.Directive`, 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 |
|--------------------|-------------|------------|----------------------|
@@ -71,7 +71,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 15bdc31..a8dcc3c 100644
--- a/docs/src/main/paradox/index.md
+++ b/docs/src/main/paradox/index.md
@@ -1,13 +1,12 @@
-Akka HTTP Quickstart for Java
-=============================
+# Apache Pekko HTTP Quickstart for Java
-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.
-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,25 +14,13 @@ 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-java/) guide
before this tutorial.
+Having a basic understanding of Pekko actors will make it easier to understand
the example.
-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 Java is a zipped project that includes a
distribution of the [sbt](http://www.scala-sbt.org) build tool, as well as
gradle and maven. Download and unzip the example as follows:
-
-1. Download the project [zip
file](https://example.lightbend.com/v1/download/akka-http-quickstart-java?name=akka-http-quickstart-java).
-2. Extract the zip file to a convenient location:
-
-* On Linux and MacOS systems, open a terminal and use the command `unzip`
akka-quickstart-java.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
-$ chmod u+x ./sbt-dist/bin/sbt
-```
-
-* On Windows, use a tool such as File Explorer to extract the project.
+Follow the instructions in
https://github.com/apache/incubator-pekko-http-quickstart-java.g8
## Running the example
@@ -41,7 +28,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-java`, and extracted the project to your root directory,
from the root directory, enter: `cd akka-http-quickstart-java`
+For example, if you used the default project name,
`pekko-http-quickstart-java`, and extracted the project to your root directory,
from the root directory, enter: `cd pekko-http-quickstart-java`
Start sbt:
@@ -52,7 +39,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 an Pekko HTTP server, and runs the example
application.
The output should look something like this:
@@ -60,17 +47,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 +160,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 three source files:
* `QuickstartApp.java` -- contains the main method which bootstraps the
application
-* `UserRoutes.java` -- Akka HTTP `routes` defining exposed endpoints
+* `UserRoutes.java` -- Pekko HTTP `routes` defining exposed endpoints
* `UserRegistry.java` -- the actor which handles the registration requests
First, let's dissect the backend logic.
diff --git a/docs/src/main/paradox/intellij-idea.md
b/docs/src/main/paradox/intellij-idea.md
index 74a076d..984f890 100644
--- a/docs/src/main/paradox/intellij-idea.md
+++ b/docs/src/main/paradox/intellij-idea.md
@@ -2,12 +2,12 @@ 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
+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.
@@ -37,6 +37,6 @@ output should look like the output in the shell:
## 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
-[documentation](http://doc.akka.io/docs/akka-http/current/java/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
+[documentation](http://pekko.apache.org/docs/pekko-http/current/java/http/index.html)
to learn more.
diff --git a/docs/src/main/paradox/json.md b/docs/src/main/paradox/json.md
index 174b6a0..16943f5 100644
--- a/docs/src/main/paradox/json.md
+++ b/docs/src/main/paradox/json.md
@@ -1,19 +1,19 @@
JSON marshalling
----------------
-When exercising the app, you interacted with JSON payloads. How does the
example app convert data between JSON format and data that can be used by Java
classes? Fur this purposes Akka HTTP has
`akka.http.javadsl.marshallers.jackson.Jackson`
+When exercising the app, you interacted with JSON payloads. How does the
example app convert data between JSON format and data that can be used by Java
classes? Fur this purposes Pekko HTTP has
`org.apache.pekko.http.javadsl.marshallers.jackson.Jackson`
-We're using the [Jackson](https://github.com/FasterXML/jackson) library here,
along with akka-http wrapper that provides marshallers `Jackson.marshaller()`.
+We're using the [Jackson](https://github.com/FasterXML/jackson) library here,
along with pekko-http wrapper that provides marshallers `Jackson.marshaller()`.
In most cases you'll just need to provide the Jackson marshaller to `complete`
call like following `complete(StatusCodes.OK, performed, Jackson.marshaller()`
to be able to product JSON response.
To create objects from JSON you'll need to create unmarshaller with class as
attribute `Jackson.unmarshaller(User.class)`
That will work out of the box where you are using mutable Java Bean style
objects with getters and setters but
-in this sample we have instead used immutable messages and domain model
classes which has no other methods than a constructor, the fields are all final
and public. To make Jacksson understand how to create such objects from JSON
this we need to provide some extra metadata in the form of the annotations
`@JsonCreator` and `@JsonProperty`:
+in this sample we have instead used immutable messages and domain model
classes which has no other methods than a constructor, the fields are all final
and public. To make Jackson understand how to create such objects from JSON
this we need to provide some extra metadata in the form of the annotations
`@JsonCreator` and `@JsonProperty`:
@@snip [UserRegistryActor.java]($g8src$/java/$package$/UserRegistry.java) {
#user-case-classes }
-While we used Jackson JSON in this example, the API is pluggable and various
other libraries can be used. Each library comes with different trade-offs in
performance and user-friendlieness. Still Jackson is the default Java
marshaller as that is what we expect Java developers to be most familiar with.
+While we used Jackson JSON in this example, the API is pluggable and various
other libraries can be used. Each library comes with different trade-offs in
performance and user-friendliness. Still Jackson is the default Java marshaller
as that is what we expect Java developers to be most familiar with.
Now that we've examined the example app thoroughly, let's test a few remaining
use cases.
diff --git a/docs/src/main/paradox/running-the-application.md
b/docs/src/main/paradox/running-the-application.md
index be3431c..946d111 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 run 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 73043d9..e464bfe 100644
--- a/docs/src/main/paradox/testing-routes.md
+++ b/docs/src/main/paradox/testing-routes.md
@@ -7,15 +7,15 @@ This separation, other than being a good idea on its own, was
all for this momen
## Unit testing routes
-There are multiple ways one can test an HTTP application of course, but 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 and separation between the network layer
(represented as a bi-directional `Flow` of byte strings to Http domain objects).
+There are multiple ways one can test an HTTP application of course, but 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 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, 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.
+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
Pekko.
First we'll need to extend a number of base traits:
@@snip [QuickstartServer.java]($g8srctest$/java/$package$/UserRoutesTest.java)
{ #test-top }
-Here we're using `JUnitRouteTest` which provides ability to test akka-http
routes.
+Here we're using `JUnitRouteTest` which provides ability to test pekko-http
routes.
Next, we'll need to bring into the test class our routes that we want to test.
We're doing this by wrapping put rout
into `TestRoute` by using `testRoute(server.createRoute())` to be able to
provide request parameters to emulate HTTP call
@@ -63,7 +63,7 @@ Sometimes, however, one wants to test the complete "full
application", including
If you want to test specific timing and entity draining behaviors 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.
+ 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 f3ea420..4f96752 100644
--- a/project/paradox.sbt
+++ b/project/paradox.sbt
@@ -1 +1,9 @@
-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/build.gradle b/src/main/g8/build.gradle
index 52bb13d..c19ff4f 100644
--- a/src/main/g8/build.gradle
+++ b/src/main/g8/build.gradle
@@ -5,27 +5,24 @@ apply plugin: 'application'
repositories {
mavenCentral()
mavenLocal()
- maven {
- url "https://repo.akka.io/maven"
- }
}
def versions = [
- AkkaVersion: "$akka_version$",
- AkkaHttpVersion: "$akka_http_version$",
+ PekkoVersion: "$pekko_version$",
+ PekkoHttpVersion: "$pekko_http_version$",
ScalaBinary: "2.13"
]
dependencies {
- implementation
platform("com.typesafe.akka:akka-http-bom_\${versions.ScalaBinary}:\${versions.AkkaHttpVersion}")
+ implementation
platform("org.apache.pekko:pekko-http-bom_\${versions.ScalaBinary}:\${versions.PekkoHttpVersion}")
- implementation "com.typesafe.akka:akka-http_\${versions.ScalaBinary}"
- implementation
"com.typesafe.akka:akka-http-jackson_\${versions.ScalaBinary}"
- implementation
"com.typesafe.akka:akka-actor-typed_\${versions.ScalaBinary}:\${versions.AkkaVersion}"
- implementation
"com.typesafe.akka:akka-stream_\${versions.ScalaBinary}:\${versions.AkkaVersion}"
- implementation 'ch.qos.logback:logback-classic:1.2.3'
- testImplementation
"com.typesafe.akka:akka-http-testkit_\${versions.ScalaBinary}"
- testImplementation
"com.typesafe.akka:akka-actor-testkit-typed_\${versions.ScalaBinary}:\${versions.AkkaVersion}"
- testImplementation 'junit:junit:4.12'
+ implementation "org.apache.pekko:pekko-http_\${versions.ScalaBinary}"
+ implementation
"org.apache.pekko:pekko-http-jackson_\${versions.ScalaBinary}"
+ implementation
"org.apache.pekko:pekko-actor-typed_\${versions.ScalaBinary}:\${versions.PekkoVersion}"
+ implementation
"org.apache.pekko:pekko-stream_\${versions.ScalaBinary}:\${versions.PekkoVersion}"
+ implementation 'ch.qos.logback:logback-classic:1.2.13'
+ testImplementation
"org.apache.pekko:pekko-http-testkit_\${versions.ScalaBinary}"
+ testImplementation
"org.apache.pekko:pekko-actor-testkit-typed_\${versions.ScalaBinary}:\${versions.PekkoVersion}"
+ testImplementation 'junit:junit:4.13.2'
}
mainClassName = "$package$.QuickstartApp"
diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt
index d4092e6..e660244 100644
--- a/src/main/g8/build.sbt
+++ b/src/main/g8/build.sbt
@@ -1,26 +1,24 @@
-val akkaHttpVersion = "$akka_http_version$"
-val akkaVersion = "$akka_version$"
-
-resolvers += "Akka library repository".at("https://repo.akka.io/maven")
+val pekkoHttpVersion = "$pekko_http_version$"
+val pekkoVersion = "$pekko_version$"
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "$organization$",
- scalaVersion := "2.13.1",
+ scalaVersion := "2.13.12",
name := "$name$"
)),
name := "TestProject",
libraryDependencies ++= Seq(
- "com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
- "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
- "com.typesafe.akka" %% "akka-stream" % akkaVersion,
- "com.typesafe.akka" %% "akka-http-jackson" % akkaHttpVersion,
- "ch.qos.logback" % "logback-classic" % "1.2.3",
+ "org.apache.pekko" %% "pekko-http" % pekkoHttpVersion,
+ "org.apache.pekko" %% "pekko-actor-typed" % pekkoVersion,
+ "org.apache.pekko" %% "pekko-stream" % pekkoVersion,
+ "org.apache.pekko" %% "pekko-http-jackson" % pekkoHttpVersion,
+ "ch.qos.logback" % "logback-classic" % "1.2.13",
- "com.typesafe.akka" %% "akka-testkit" % akkaVersion
% Test,
- "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion
% Test,
- "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion
% Test,
+ "org.apache.pekko" %% "pekko-testkit" % pekkoVersion
% Test,
+ "org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpVersion
% Test,
+ "org.apache.pekko" %% "pekko-actor-testkit-typed" % pekkoVersion
% Test,
"junit" % "junit" % "4.12"
% Test,
"com.novocode" % "junit-interface" % "0.10"
% Test
),
diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties
index a407715..5004b96 100644
--- a/src/main/g8/default.properties
+++ b/src/main/g8/default.properties
@@ -1,6 +1,6 @@
-name=My Akka HTTP Project
-akka_http_version=10.6.0
-akka_version=2.9.0
+name=My Pekko HTTP Project
+pekko_http_version=1.0.0
+pekko_version=1.0.2
organization=com.example
package=$organization$
verbatim=gradlew gradlew.bat gradle-wrapper.properties gradle-wrapper.jar
\ No newline at end of file
diff --git a/src/main/g8/pom.xml b/src/main/g8/pom.xml
index a0ad666..b6cb071 100644
--- a/src/main/g8/pom.xml
+++ b/src/main/g8/pom.xml
@@ -3,30 +3,22 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
- <artifactId>akka-http-seed-java</artifactId>
+ <artifactId>pekko-http-seed-java</artifactId>
<version>1.0</version>
<properties>
- <akka.version>$akka_version$</akka.version>
- <akka.http.version>$akka_http_version$</akka.http.version>
+ <pekko.version>$pekko_version$</pekko.version>
+ <pekko.http.version>$pekko_http_version$</pekko.http.version>
<scala.binary.version>2.13</scala.binary.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
- <repositories>
- <repository>
- <id>akka-repository</id>
- <name>Akka library repository</name>
- <url>https://repo.akka.io/maven</url>
- </repository>
- </repositories>
-
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-http-bom_\${scala.binary.version}</artifactId>
- <version>\${akka.http.version}</version>
+ <groupId>org.apache.pekko</groupId>
+
<artifactId>pekko-http-bom_\${scala.binary.version}</artifactId>
+ <version>\${pekko.http.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -35,37 +27,37 @@
<dependencies>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-http_\${scala.binary.version}</artifactId>
+ <groupId>org.apache.pekko</groupId>
+ <artifactId>pekko-http_\${scala.binary.version}</artifactId>
</dependency>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-actor-typed_\${scala.binary.version}</artifactId>
- <version>\${akka.version}</version>
+ <groupId>org.apache.pekko</groupId>
+ <artifactId>pekko-actor-typed_\${scala.binary.version}</artifactId>
+ <version>\${pekko.version}</version>
</dependency>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-stream_\${scala.binary.version}</artifactId>
- <version>\${akka.version}</version>
+ <groupId>org.apache.pekko</groupId>
+ <artifactId>pekko-stream_\${scala.binary.version}</artifactId>
+ <version>\${pekko.version}</version>
</dependency>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-http-jackson_\${scala.binary.version}</artifactId>
+ <groupId>org.apache.pekko</groupId>
+
<artifactId>pekko-http-jackson_\${scala.binary.version}</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.11</version>
+ <version>1.2.13</version>
</dependency>
<dependency>
- <groupId>com.typesafe.akka</groupId>
- <artifactId>akka-http-testkit_\${scala.binary.version}</artifactId>
+ <groupId>org.apache.pekko</groupId>
+
<artifactId>pekko-http-testkit_\${scala.binary.version}</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.typesafe.akka</groupId>
-
<artifactId>akka-actor-testkit-typed_\${scala.binary.version}</artifactId>
- <version>\${akka.version}</version>
+ <groupId>org.apache.pekko</groupId>
+
<artifactId>pekko-actor-testkit-typed_\${scala.binary.version}</artifactId>
+ <version>\${pekko.version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/src/main/g8/project/build.properties
b/src/main/g8/project/build.properties
index 2743082..e8a1e24 100644
--- a/src/main/g8/project/build.properties
+++ b/src/main/g8/project/build.properties
@@ -1 +1 @@
-sbt.version=1.9.6
+sbt.version=1.9.7
diff --git a/src/main/g8/src/main/java/$package$/QuickstartApp.java
b/src/main/g8/src/main/java/$package$/QuickstartApp.java
index 43e7b80..c9d51c4 100644
--- a/src/main/g8/src/main/java/$package$/QuickstartApp.java
+++ b/src/main/g8/src/main/java/$package$/QuickstartApp.java
@@ -1,19 +1,19 @@
package $package$;
-import akka.NotUsed;
-import akka.actor.typed.ActorRef;
-import akka.actor.typed.Behavior;
-import akka.http.javadsl.ConnectHttp;
-import akka.http.javadsl.Http;
-import akka.http.javadsl.ServerBinding;
-import akka.http.javadsl.model.HttpRequest;
-import akka.http.javadsl.model.HttpResponse;
-import akka.http.javadsl.server.Route;
-import akka.stream.Materializer;
-import akka.stream.javadsl.Flow;
-import akka.actor.typed.javadsl.Adapter;
-import akka.actor.typed.javadsl.Behaviors;
-import akka.actor.typed.ActorSystem;
+import org.apache.pekko.NotUsed;
+import org.apache.pekko.actor.typed.ActorRef;
+import org.apache.pekko.actor.typed.Behavior;
+import org.apache.pekko.http.javadsl.ConnectHttp;
+import org.apache.pekko.http.javadsl.Http;
+import org.apache.pekko.http.javadsl.ServerBinding;
+import org.apache.pekko.http.javadsl.model.HttpRequest;
+import org.apache.pekko.http.javadsl.model.HttpResponse;
+import org.apache.pekko.http.javadsl.server.Route;
+import org.apache.pekko.stream.Materializer;
+import org.apache.pekko.stream.javadsl.Flow;
+import org.apache.pekko.actor.typed.javadsl.Adapter;
+import org.apache.pekko.actor.typed.javadsl.Behaviors;
+import org.apache.pekko.actor.typed.ActorSystem;
import java.net.InetSocketAddress;
import java.util.concurrent.CompletionStage;
@@ -52,7 +52,7 @@ public class QuickstartApp {
});
// boot up server using the route as defined below
- ActorSystem.create(rootBehavior, "HelloAkkaHttpServer");
+ ActorSystem.create(rootBehavior, "HelloPekkoHttpServer");
//#server-bootstrapping
}
diff --git a/src/main/g8/src/main/java/$package$/UserRegistry.java
b/src/main/g8/src/main/java/$package$/UserRegistry.java
index 1290173..7188267 100644
--- a/src/main/g8/src/main/java/$package$/UserRegistry.java
+++ b/src/main/g8/src/main/java/$package$/UserRegistry.java
@@ -1,11 +1,11 @@
package $package$;
-import akka.actor.typed.ActorRef;
-import akka.actor.typed.Behavior;
-import akka.actor.typed.javadsl.AbstractBehavior;
-import akka.actor.typed.javadsl.ActorContext;
-import akka.actor.typed.javadsl.Behaviors;
-import akka.actor.typed.javadsl.Receive;
+import org.apache.pekko.actor.typed.ActorRef;
+import org.apache.pekko.actor.typed.Behavior;
+import org.apache.pekko.actor.typed.javadsl.AbstractBehavior;
+import org.apache.pekko.actor.typed.javadsl.ActorContext;
+import org.apache.pekko.actor.typed.javadsl.Behaviors;
+import org.apache.pekko.actor.typed.javadsl.Receive;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/src/main/g8/src/main/java/$package$/UserRoutes.java
b/src/main/g8/src/main/java/$package$/UserRoutes.java
index 3626d15..950c57f 100644
--- a/src/main/g8/src/main/java/$package$/UserRoutes.java
+++ b/src/main/g8/src/main/java/$package$/UserRoutes.java
@@ -5,17 +5,17 @@ import java.util.Optional;
import java.util.concurrent.CompletionStage;
import $package$.UserRegistry.User;
-import akka.actor.typed.ActorRef;
-import akka.actor.typed.ActorSystem;
-import akka.actor.typed.Scheduler;
-import akka.actor.typed.javadsl.AskPattern;
-import akka.http.javadsl.marshallers.jackson.Jackson;
+import org.apache.pekko.actor.typed.ActorRef;
+import org.apache.pekko.actor.typed.ActorSystem;
+import org.apache.pekko.actor.typed.Scheduler;
+import org.apache.pekko.actor.typed.javadsl.AskPattern;
+import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson;
-import static akka.http.javadsl.server.Directives.*;
+import static org.apache.pekko.http.javadsl.server.Directives.*;
-import akka.http.javadsl.model.StatusCodes;
-import akka.http.javadsl.server.PathMatchers;
-import akka.http.javadsl.server.Route;
+import org.apache.pekko.http.javadsl.model.StatusCodes;
+import org.apache.pekko.http.javadsl.server.PathMatchers;
+import org.apache.pekko.http.javadsl.server.Route;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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/test/java/$package$/UserRoutesTest.java
b/src/main/g8/src/test/java/$package$/UserRoutesTest.java
index 8ef7f08..af84503 100644
--- a/src/main/g8/src/test/java/$package$/UserRoutesTest.java
+++ b/src/main/g8/src/test/java/$package$/UserRoutesTest.java
@@ -2,15 +2,15 @@ package $package$;
//#test-top
-import akka.actor.typed.ActorRef;
-import akka.http.javadsl.model.*;
-import akka.http.javadsl.testkit.JUnitRouteTest;
-import akka.http.javadsl.testkit.TestRoute;
+import org.apache.pekko.actor.typed.ActorRef;
+import org.apache.pekko.http.javadsl.model.*;
+import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest;
+import org.apache.pekko.http.javadsl.testkit.TestRoute;
import org.junit.*;
import org.junit.runners.MethodSorters;
-import akka.http.javadsl.model.HttpRequest;
-import akka.http.javadsl.model.StatusCodes;
-import akka.actor.testkit.typed.javadsl.TestKitJunitResource;
+import org.apache.pekko.http.javadsl.model.HttpRequest;
+import org.apache.pekko.http.javadsl.model.StatusCodes;
+import org.apache.pekko.actor.testkit.typed.javadsl.TestKitJunitResource;
//#set-up
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]