refactor: refined the endpoint-uri's
authorKai Moritz <kai@juplo.de>
Wed, 11 Jan 2023 20:41:46 +0000 (21:41 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 25 Jan 2023 20:59:37 +0000 (21:59 +0100)
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java
src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java

index 3b8fc84..d0d2763 100644 (file)
@@ -32,7 +32,7 @@ public class ChatBackendController
     return chatHome.getChatRooms().map(chatroom -> ChatRoomTo.from(chatroom));
   }
 
-  @GetMapping("list/{chatroomId}")
+  @GetMapping("{chatroomId}/list")
   public Flux<MessageTo> list(@PathVariable UUID chatroomId)
   {
     return chatHome
@@ -42,13 +42,13 @@ public class ChatBackendController
             .map(MessageTo::from));
   }
 
-  @GetMapping("get/{chatroomId}")
+  @GetMapping("{chatroomId}")
   public Mono<ChatRoomTo> get(@PathVariable UUID chatroomId)
   {
     return chatHome.getChatRoom(chatroomId).map(chatroom -> ChatRoomTo.from(chatroom));
   }
 
-  @PutMapping("put/{chatroomId}/{username}/{messageId}")
+  @PutMapping("{chatroomId}/{username}/{messageId}")
   public Mono<MessageTo> put(
       @PathVariable UUID chatroomId,
       @PathVariable String username,
@@ -76,7 +76,7 @@ public class ChatBackendController
             .map(message -> MessageTo.from(message));
   }
 
-  @GetMapping("get/{chatroomId}/{username}/{messageId}")
+  @GetMapping("{chatroomId}/{username}/{messageId}")
   public Mono<MessageTo> get(
       @PathVariable UUID chatroomId,
       @PathVariable String username,
@@ -99,7 +99,7 @@ public class ChatBackendController
             .map(message -> MessageTo.from(message));
   }
 
-  @GetMapping(path = "listen/{chatroomId}")
+  @GetMapping(path = "{chatroomId}/listen")
   public Flux<ServerSentEvent<MessageTo>> listen(@PathVariable UUID chatroomId)
   {
     return chatHome
index eeaf5ee..403c9d5 100644 (file)
@@ -41,7 +41,7 @@ public class ChatBackendControllerTest
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/list/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}/list", chatroomId)
         .accept(MediaType.APPLICATION_JSON)
         .exchange();
 
@@ -61,7 +61,7 @@ public class ChatBackendControllerTest
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/get/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}", chatroomId)
         .accept(MediaType.APPLICATION_JSON)
         .exchange();
 
@@ -83,7 +83,7 @@ public class ChatBackendControllerTest
     WebTestClient.ResponseSpec responseSpec = client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             username,
             messageId)
@@ -109,7 +109,7 @@ public class ChatBackendControllerTest
     WebTestClient.ResponseSpec responseSpec = client
         .get()
         .uri(
-            "/get/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             username,
             messageId)
@@ -131,7 +131,7 @@ public class ChatBackendControllerTest
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/listen/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}/listen", chatroomId)
         // .accept(MediaType.TEXT_EVENT_STREAM, MediaType.APPLICATION_JSON) << TODO: Does not work!
         .exchange();
 
@@ -185,7 +185,7 @@ public class ChatBackendControllerTest
     client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             user,
             messageId)
@@ -232,7 +232,7 @@ public class ChatBackendControllerTest
     client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             user,
             messageId)