From f3cd5308c0c379a23d0c2ad3f1522f04c7da0d85 Mon Sep 17 00:00:00 2001 From: Andrzej Ludwikowski Date: Fri, 15 Dec 2023 11:17:57 +0100 Subject: [PATCH] fix: Hello world action exposed to the internet in code first archetypes (#1920) --- .../hello/HelloWorld.java | 21 +++++++++++++++++++ .../resources/archetype-resources/pom.xml | 2 +- .../hello/HelloWorld.kt | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/src/main/java/__packageInPathFormat__/hello/HelloWorld.java create mode 100644 maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/src/main/kotlin/__packageInPathFormat__/hello/HelloWorld.kt diff --git a/maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/src/main/java/__packageInPathFormat__/hello/HelloWorld.java b/maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/src/main/java/__packageInPathFormat__/hello/HelloWorld.java new file mode 100644 index 0000000000..26d0f60df5 --- /dev/null +++ b/maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/src/main/java/__packageInPathFormat__/hello/HelloWorld.java @@ -0,0 +1,21 @@ +package ${package}.hello; + +import kalix.javasdk.action.Action; +import kalix.javasdk.annotations.Acl; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * This is a simple Action that returns "Hello World!". + * Locally, you can access it by running `curl http://localhost:9000/hello`. + */ +@RequestMapping +// Exposing action to the Internet. +@Acl(allow = @Acl.Matcher(principal = Acl.Principal.INTERNET)) +public class HelloWorld extends Action { + + @GetMapping("/hello") + public Action.Effect hello() { + return effects().reply("Hello World!"); + } +} \ No newline at end of file diff --git a/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/pom.xml b/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/pom.xml index 9eac94b15e..90d7637d49 100644 --- a/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/pom.xml +++ b/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/pom.xml @@ -24,7 +24,7 @@ ${D}{kalixContainerRegistry}/${D}{kalixOrganization}/${D}{project.artifactId} ${project.version}-${build.timestamp} yyyyMMddHHmmss - ${package}.Main + ${package}.MainKt 17 UTF-8 diff --git a/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/src/main/kotlin/__packageInPathFormat__/hello/HelloWorld.kt b/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/src/main/kotlin/__packageInPathFormat__/hello/HelloWorld.kt new file mode 100644 index 0000000000..327eca5318 --- /dev/null +++ b/maven-java/kalix-spring-boot-kotlin-archetype/src/main/resources/archetype-resources/src/main/kotlin/__packageInPathFormat__/hello/HelloWorld.kt @@ -0,0 +1,21 @@ +package ${package}.hello; + +import kalix.javasdk.action.Action +import kalix.javasdk.annotations.Acl +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping + +/** + * This is a simple Action that returns "Hello World!". + * Locally, you can access it by running `curl http://localhost:9000/hello`. + */ +@RequestMapping +// Exposing action to the Internet. +@Acl(allow = [Acl.Matcher(principal = Acl.Principal.INTERNET)]) +class HelloWorld : Action() { + + @GetMapping("/hello") + fun hello(): Effect { + return effects().reply("Hello World!") + } +} \ No newline at end of file