From: Kai Moritz Date: Sun, 12 Jul 2020 09:37:56 +0000 (+0200) Subject: WIP X-Git-Tag: wip-initial~14 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=5dea0011f01dac3a691a30bb0cd9495252f67d8b;p=demos%2Fspring%2Fdata-jdbc WIP --- 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(); } }