From e05af3f6f0fb49068a64f599c8e82f95d69e7a2f Mon Sep 17 00:00:00 2001 From: YoungJun Park Date: Tue, 16 Aug 2022 23:37:29 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=94=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20WebClient=20=ED=98=B8=EC=B6=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20(#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket/service/ChatRoomService.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 socket/src/main/java/hexagonal/socket/service/ChatRoomService.java diff --git a/socket/src/main/java/hexagonal/socket/service/ChatRoomService.java b/socket/src/main/java/hexagonal/socket/service/ChatRoomService.java new file mode 100644 index 0000000..1aed034 --- /dev/null +++ b/socket/src/main/java/hexagonal/socket/service/ChatRoomService.java @@ -0,0 +1,25 @@ +package hexagonal.socket.service; + +import hexagonal.socket.dto.RoomInfo; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.client.WebClient; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class ChatRoomService { + + private final WebClient webClient = WebClient.builder() + .baseUrl("http://localhost:8080") + .build(); + + public List getRoomInfoList() { + return webClient.get() + .uri("/v1/room/list") + .retrieve() + .bodyToFlux(RoomInfo.class) + .toStream() + .collect(Collectors.toList()); + } +}