Implemented an interceptor, that forbiddes access according to a header
[demos/spring-boot] / src / main / java / de / juplo / demo / DemoRestController.java
index 4259a30..ed364a0 100644 (file)
@@ -17,8 +17,9 @@ public class DemoRestController
   private final String from;
 
 
-  @PostMapping("{to}")
-  public GreetingTO greet(
+  @RequestableByHumans
+  @PostMapping("/greet/{to}")
+  public MessageTo greet(
       @PathVariable String to,
       @RequestBody String greeting)
   {
@@ -29,6 +30,21 @@ public class DemoRestController
 
     log.info("Greeting from {} to {}: {}", from, to, message);
 
-    return GreetingTO.of(message, from, to);
+    return MessageTo.of(message, from, to);
+  }
+
+  @PostMapping("/acknowledge/{to}")
+  public MessageTo acknowledge(
+      @PathVariable String to,
+      @RequestBody String acknowledgment)
+  {
+    String message = acknowledgment
+        .replaceAll(PLACEHOLDER_FROM, from)
+        .replaceAll(PLACEHOLDER_TO, to)
+        .trim();
+
+    log.info("Acknowledgement from {} to {}: {}", from, to, message);
+
+    return MessageTo.of(message, from, to);
   }
 }