WIP
authorKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 12:57:52 +0000 (14:57 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 12:57:52 +0000 (14:57 +0200)
src/main/java/de/juplo/boot/data/jdbc/UserController.java

index 1ff11d8..513ec5a 100644 (file)
@@ -52,6 +52,18 @@ public class UserController {
         return ResponseEntity.ok(user);
     }
 
+    @DeleteMapping("{username}")
+    public ResponseEntity<User> removeUser(@PathVariable String username) {
+        User user = repository.findByUsername(UserController.sanitize(username));
+
+        if (user == null)
+            return ResponseEntity.notFound().build();
+
+        repository.delete(user);
+
+        return ResponseEntity.ok(user);
+    }
+
     @GetMapping()
     public ResponseEntity<Iterable<User>> getUsers() {
         return ResponseEntity.ok(repository.findAll());