From 5dea0011f01dac3a691a30bb0cd9495252f67d8b Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 12 Jul 2020 11:37:56 +0200 Subject: [PATCH] WIP --- .../java/de/trion/kafka/outbox/OutboxController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/trion/kafka/outbox/OutboxController.java b/src/main/java/de/trion/kafka/outbox/OutboxController.java index f1119f2..e1f8919 100644 --- a/src/main/java/de/trion/kafka/outbox/OutboxController.java +++ b/src/main/java/de/trion/kafka/outbox/OutboxController.java @@ -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 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(); } } -- 2.20.1