Fixes für Setup/README.sh aus 'deserialization' in 'stored-offsets' gemerged
[demos/kafka/training] / src / main / java / de / juplo / kafka / DriverController.java
index 28aa69f..f6ff47f 100644 (file)
@@ -1,10 +1,10 @@
 package de.juplo.kafka;
 
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.Map;
 import java.util.concurrent.ExecutionException;
 
 
@@ -13,6 +13,7 @@ import java.util.concurrent.ExecutionException;
 public class DriverController
 {
   private final EndlessConsumer consumer;
+  private final KeyCountingRecordHandler keyCountingRecordHandler;
 
 
   @PostMapping("start")
@@ -27,9 +28,18 @@ public class DriverController
     consumer.stop();
   }
 
+
+  @GetMapping("seen")
+  public Map<Integer, Map<String, Long>> seen()
+  {
+    return keyCountingRecordHandler.getSeen();
+  }
+
+
   @ExceptionHandler
+  @ResponseStatus(HttpStatus.BAD_REQUEST)
   public ErrorResponse illegalStateException(IllegalStateException e)
   {
-    return new ErrorResponse(e.getMessage(), 400);
+    return new ErrorResponse(e.getMessage(), HttpStatus.BAD_REQUEST.value());
   }
 }