WIP
authorKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 09:37:56 +0000 (11:37 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 09:37:56 +0000 (11:37 +0200)
src/main/java/de/trion/kafka/outbox/OutboxController.java

index f1119f2..e1f8919 100644 (file)
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.http.ResponseEntity;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
 import org.springframework.web.util.UriComponents;
 import org.springframework.web.util.UriComponentsBuilder;
 
@@ -26,15 +27,19 @@ public class OutboxController {
     }
 
 
-    @PostMapping()
+    @PostMapping
     public ResponseEntity<Void> getVorgang(
-            UriComponentsBuilder builder,
+            ServletUriComponentsBuilder builder,
             @RequestBody String username) {
         String cleaned = username.trim().toLowerCase();
         User user = new User(cleaned, LocalDateTime.now(), false);
         repository.save(user);
         // TODO: Not-Unique Fehler auslösen
-        UriComponents uri = builder.path("{username}").buildAndExpand(cleaned);
+        UriComponents uri =
+                builder
+                    .fromCurrentRequest()
+                    .path("{username}")
+                    .buildAndExpand(cleaned);
         return ResponseEntity.created(uri.toUri()).build();
     }
 }