You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by fa...@apache.org on 2022/10/31 09:35:30 UTC

[incubator-pekko-samples] branch createStation created (now 6813a94)

This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a change to branch createStation
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-samples.git


      at 6813a94  Station creation

This branch includes the following new commits:

     new 6813a94  Station creation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org


[incubator-pekko-samples] 01/01: Station creation

Posted by fa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch createStation
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-samples.git

commit 6813a94c0dca08d5dc754ca2fb522e636ea346f3
Author: Arnout Engelen <ar...@bzzt.net>
AuthorDate: Fri Nov 1 15:58:08 2019 +0100

    Station creation
---
 .../src/main/scala/sample/sharding/WeatherRoutes.scala | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/akka-sample-sharding-scala/src/main/scala/sample/sharding/WeatherRoutes.scala b/akka-sample-sharding-scala/src/main/scala/sample/sharding/WeatherRoutes.scala
index 70eb21f..0bc274e 100644
--- a/akka-sample-sharding-scala/src/main/scala/sample/sharding/WeatherRoutes.scala
+++ b/akka-sample-sharding-scala/src/main/scala/sample/sharding/WeatherRoutes.scala
@@ -34,11 +34,19 @@ class WeatherRoutes(guardian: ActorRef[Guardian.Command])(implicit system: Actor
         }
       },
       pathPrefix("weather-stations") {
-        get {
-          onComplete((guardian ? GetWeatherStations).mapTo[WeatherStations]) {
-            case Success(value) => complete(s"The result was $value")
-            case Failure(e)     => complete((StatusCodes.InternalServerError, s"An error occurred: ${e.getMessage}"))
+        concat(
+          get {
+            onComplete((guardian ? GetWeatherStations).mapTo[WeatherStations]) {
+              case Success(value) => complete(s"The result was $value")
+              case Failure(e)     => complete((StatusCodes.InternalServerError, s"An error occurred: ${e.getMessage}"))
+            }
+          },
+          // REST-wise we should expect PUT here, but let's be lenient and also accept POST:
+          (path(IntNumber) & (put | post)) { sid =>
+            // This command is 'fire and forget'
+            guardian ! AddWeatherStation(sid)
+            complete(StatusCodes.Accepted)
           }
-        }
+        )
       })
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org