diff --git a/README.md b/README.md
index 5e6c077..2f9d82a 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
A template project to create a Docker image for a Java application.
The [example application](src/main/java/com/miguno/javadockerbuild/App.java)
uses Spring Boot to expose an HTTP endpoint at
-[`/status`](http://localhost:8123/status).
+[`/welcome`](http://localhost:8123/welcome).
> **Golang developer?** Check out https://github.com/miguno/golang-docker-build-tutorial
@@ -93,7 +93,7 @@ $ docker run -p 8123:8123 miguno/java-docker-build-tutorial:latest
```
Running container from docker image ...
Starting container for image 'miguno/java-docker-build-tutorial:latest', exposing port 8123/tcp
-- Run 'curl http://localhost:8123/status' to send a test request to the containerized app.
+- Run 'curl http://localhost:8123/welcome' to send a test request to the containerized app.
- Enter Ctrl-C to stop the container.
. ____ _ __ _ _
@@ -123,8 +123,8 @@ Starting container for image 'miguno/java-docker-build-tutorial:latest', exposin
running container.
```shell
-$ curl http://localhost:8123/status
-{"status":"idle"}
+$ curl http://localhost:8123/welcome
+{"welcome":"Hello, World!"}
```
# Local usage without Docker
diff --git a/justfile b/justfile
index 2ed3b92..39628ef 100644
--- a/justfile
+++ b/justfile
@@ -33,13 +33,13 @@ audit:
# benchmark the app's HTTP endpoint with plow (requires https://github.com/six-ddc/plow)
benchmark-plow:
- @echo plow -c 100 --duration=30s http://localhost:${APP_PORT}/status
- @plow -c 100 --duration=30s http://localhost:${APP_PORT}/status
+ @echo plow -c 100 --duration=30s http://localhost:${APP_PORT}/welcome
+ @plow -c 100 --duration=30s http://localhost:${APP_PORT}/welcome
# benchmark the app's HTTP endpoint with wrk (requires https://github.com/wg/wrk)
benchmark-wrk:
- @echo wrk -t 10 -c 100 --latency --duration 30 http://localhost:${APP_PORT}/status
- @wrk -t 10 -c 100 --latency --duration 30 http://localhost:${APP_PORT}/status
+ @echo wrk -t 10 -c 100 --latency --duration 30 http://localhost:${APP_PORT}/welcome
+ @wrk -t 10 -c 100 --latency --duration 30 http://localhost:${APP_PORT}/welcome
# alias for 'compile'
build: compile
@@ -135,8 +135,8 @@ site: compile
# send request to the app's HTTP endpoint (requires Docker and running app container)
send-request-to-app:
- @echo curl http://localhost:${APP_PORT}/status
- @curl http://localhost:${APP_PORT}/status
+ @echo curl http://localhost:${APP_PORT}/welcome
+ @curl http://localhost:${APP_PORT}/welcome
# static code analysis with spotbugs
spotbugs: compile
diff --git a/src/main/java/com/miguno/javadockerbuild/admin/SecuritySecureConfig.java b/src/main/java/com/miguno/javadockerbuild/admin/SecuritySecureConfig.java
index 3eed185..aba39ca 100644
--- a/src/main/java/com/miguno/javadockerbuild/admin/SecuritySecureConfig.java
+++ b/src/main/java/com/miguno/javadockerbuild/admin/SecuritySecureConfig.java
@@ -93,8 +93,8 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
//// For the Spring Boot Admin client (the "real" app being developed).
.requestMatchers(
new AntPathRequestMatcher("/"),
- // Permit public access to this app's example endpoint at `/status`.
- new AntPathRequestMatcher("/status"),
+ // Permit public access to this app's example endpoint at `/welcome`.
+ new AntPathRequestMatcher("/welcome"),
// Permit public access to Swagger.
new AntPathRequestMatcher("/swagger-ui.html"),
new AntPathRequestMatcher("/v3/api-docs"),
diff --git a/src/main/java/com/miguno/javadockerbuild/controllers/RootController.java b/src/main/java/com/miguno/javadockerbuild/controllers/RootController.java
index e2ac7c7..f99b8c5 100644
--- a/src/main/java/com/miguno/javadockerbuild/controllers/RootController.java
+++ b/src/main/java/com/miguno/javadockerbuild/controllers/RootController.java
@@ -39,7 +39,7 @@ public String root() {
Enjoy playing around with this application!
Example Endpoints
- /status
— this app's example endpoint
+ /welcome
— this app's example endpoint
/actuator/health
— Spring built-in feature
/actuator/prometheus
— Spring built-in feature
- Spring Boot Admin dashboard (requires login, see below)
diff --git a/src/main/java/com/miguno/javadockerbuild/controllers/StatusController.java b/src/main/java/com/miguno/javadockerbuild/controllers/WelcomeController.java
similarity index 60%
rename from src/main/java/com/miguno/javadockerbuild/controllers/StatusController.java
rename to src/main/java/com/miguno/javadockerbuild/controllers/WelcomeController.java
index dcc2528..8093ad5 100644
--- a/src/main/java/com/miguno/javadockerbuild/controllers/StatusController.java
+++ b/src/main/java/com/miguno/javadockerbuild/controllers/WelcomeController.java
@@ -1,6 +1,6 @@
package com.miguno.javadockerbuild.controllers;
-import com.miguno.javadockerbuild.models.Status;
+import com.miguno.javadockerbuild.models.Welcome;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -9,18 +9,18 @@
/** The only API endpoint exposed by this example application. */
@SuppressFBWarnings("SPRING_ENDPOINT")
@RestController
-public class StatusController {
+public class WelcomeController {
private static final String template = "Hello, %s!";
/**
- * Returns a greeting to the client.
+ * Returns a welcome message to the client.
*
* @param name The name to greet.
- * @return A personalized greeting.
+ * @return A personalized welcome message.
*/
- @GetMapping("/status")
- public Status status(@RequestParam(value = "name", defaultValue = "World") String name) {
- return new Status(String.format(template, name));
+ @GetMapping("/welcome")
+ public Welcome welcome(@RequestParam(value = "name", defaultValue = "World") String name) {
+ return new Welcome(String.format(template, name));
}
}
diff --git a/src/main/java/com/miguno/javadockerbuild/models/Status.java b/src/main/java/com/miguno/javadockerbuild/models/Welcome.java
similarity index 51%
rename from src/main/java/com/miguno/javadockerbuild/models/Status.java
rename to src/main/java/com/miguno/javadockerbuild/models/Welcome.java
index d04b8cc..9a5dad8 100644
--- a/src/main/java/com/miguno/javadockerbuild/models/Status.java
+++ b/src/main/java/com/miguno/javadockerbuild/models/Welcome.java
@@ -1,3 +1,3 @@
package com.miguno.javadockerbuild.models;
-public record Status(String status) {}
+public record Welcome(String welcome) {}
diff --git a/src/test/java/com/miguno/javadockerbuild/SmokeTest.java b/src/test/java/com/miguno/javadockerbuild/SmokeTest.java
index 6f7d059..bd2037a 100644
--- a/src/test/java/com/miguno/javadockerbuild/SmokeTest.java
+++ b/src/test/java/com/miguno/javadockerbuild/SmokeTest.java
@@ -1,6 +1,6 @@
package com.miguno.javadockerbuild;
-import com.miguno.javadockerbuild.controllers.StatusController;
+import com.miguno.javadockerbuild.controllers.WelcomeController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -8,7 +8,7 @@
@SpringBootTest
class SmokeTest {
- @Autowired private StatusController controller;
+ @Autowired private WelcomeController controller;
@Test
void verifyThatApplicationContextLoads() {
diff --git a/src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerIT.java b/src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerIT.java
similarity index 71%
rename from src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerIT.java
rename to src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerIT.java
index 4db0d57..48e0338 100644
--- a/src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerIT.java
+++ b/src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerIT.java
@@ -8,17 +8,17 @@
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.ResponseEntity;
-/** An example integration test for the API endpoint `/status`. */
+/** An example integration test for the API endpoint `/welcome`. */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class StatusControllerIT {
+public class WelcomeControllerIT {
@Autowired private TestRestTemplate template;
@Test
- public void getStatus() throws Exception {
- ResponseEntity response = template.getForEntity("/status", String.class);
+ public void welcome() throws Exception {
+ ResponseEntity response = template.getForEntity("/welcome", String.class);
String expectedJson = """
- {"status":"Hello, World!"}
+ {"welcome":"Hello, World!"}
""";
JSONAssert.assertEquals(expectedJson, response.getBody(), JSONCompareMode.STRICT);
}
diff --git a/src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerTest.java b/src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerTest.java
similarity index 75%
rename from src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerTest.java
rename to src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerTest.java
index afac7d5..c3d12d0 100644
--- a/src/test/java/com/miguno/javadockerbuild/controllers/StatusControllerTest.java
+++ b/src/test/java/com/miguno/javadockerbuild/controllers/WelcomeControllerTest.java
@@ -11,20 +11,20 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-/** Example unit tests for the API endpoint `/status`. */
+/** Example unit tests for the API endpoint `/welcome`. */
@SpringBootTest
@AutoConfigureMockMvc
-public class StatusControllerTest {
+public class WelcomeControllerTest {
@Autowired private MockMvc mvc;
@Test
- public void getStatus() throws Exception {
+ public void getWelcome() throws Exception {
String expectedJson = """
- {"status":"Hello, World!"}
+ {"welcome":"Hello, World!"}
""";
- mvc.perform(MockMvcRequestBuilders.get("/status").accept(MediaType.APPLICATION_JSON))
+ mvc.perform(MockMvcRequestBuilders.get("/welcome").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().json(expectedJson));
}
diff --git a/start_container.sh b/start_container.sh
index d95f305..4454eea 100755
--- a/start_container.sh
+++ b/start_container.sh
@@ -15,7 +15,7 @@ declare -r OS="$(uname -s)"
declare -r ARCH="$(uname -m)"
# Check requirements
-if ! command -v docker &> /dev/null; then
+if ! command -v docker &>/dev/null; then
echo "ERROR: 'docker' command not available. Is Docker installed?"
exit 1
fi
@@ -28,6 +28,6 @@ if [[ "$OS" = "Darwin" && "$ARCH" = "arm64" ]]; then
fi
echo "Starting container for image '$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG', exposing port ${APP_PORT}/tcp"
-echo "- Run 'curl http://localhost:${APP_PORT}/status' to send a test request to the containerized app."
+echo "- Run 'curl http://localhost:${APP_PORT}/welcome' to send a test request to the containerized app."
echo "- Enter Ctrl-C to stop the container."
docker run $DOCKER_OPTIONS -p "$APP_PORT:$APP_PORT" "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_TAG"