Skip to content

๐Ÿž Board > Rest Client: ์ž„ํฌํŠธ, Non-static ์ „ํ™˜ ๋“ฑ Nettee Client์˜ ์ˆ˜์ •์ด ๋œ ๋ฐ˜์˜๋œ ์˜์—ญ์„ ์ˆ˜์ • #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ public record ClientProperties(
Map<String, String> url
) {
public ClientProperties {
if (baseUrl == null || baseUrl.isEmpty()) {
baseUrl = "http://localhost:8080";
log.warn("baseUrl is null or empty");
} else {
baseUrl = baseUrl.strip();
}

log.debug("baseUrl url: {}", baseUrl);

for(Entry<String, String> entry : url.entrySet()) {

for (Entry<String, String> entry : url.entrySet()) {
entry.setValue(entry.getValue().strip());
log.debug((entry.getKey() + ": " + entry.getValue()));
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ boardReadModel=:board:board-api:board-readmodel
boardApplication=:board:board-application
boardRdbAdapter=:board:board-rdb-adapter
boardWebMvcAdapter=:board:board-webmvc
boardRestClient=:board:board-nettee-client
boardRestClient=:board:board-board-nettee-client

# comment
comment=:comment
Expand Down
3 changes: 1 addition & 2 deletions monolith/main-runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ dependencies {
implementation(project(":exception-handler-core"))
implementation(project(":jpa-core"))
implementation(project(":cors-webmvc"))
implementation(project(":rest-client"))

// services
implementation(project(board))

implementation(project(":rest-client"))

// webmvc
implementation("org.springframework.boot:spring-boot-starter-web")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nettee.board.port;
package nettee.board.application.port;

import nettee.board.domain.Board;

public interface BoardCommandNetteeClientPort {
Board save();
Board save(Board board);
}
4 changes: 2 additions & 2 deletions services/board/board.settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include(
boardApplication,
boardRdbAdapter,
boardWebMvcAdapter,
// boardRestClient,
boardRestClient,
)

project(board).projectDir = boardDirectory("board")
Expand All @@ -44,4 +44,4 @@ project(boardReadModel).projectDir = boardDirectory("readmodel")
project(boardApplication).projectDir = boardDirectory("application")
project(boardRdbAdapter).projectDir = boardDirectory("rdb")
project(boardWebMvcAdapter).projectDir = boardDirectory("web-mvc")
//project(boardRestClient).projectDir = boardDirectory("board-nettee-client") // don't import yet, cuz including errors
project(boardRestClient).projectDir = boardDirectory("board-nettee-client")
2 changes: 2 additions & 0 deletions services/board/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ val boardApi: String by project
val boardApplication: String by project
val boardRdbAdapter: String by project
val boardWebMvcAdapter: String by project
val boardRestClient: String by project

dependencies {
api(project(boardApi))
api(project(boardApplication))
api(project(boardRdbAdapter))
api(project(boardWebMvcAdapter))
api(project(boardRestClient))
}
6 changes: 5 additions & 1 deletion services/board/driven/board-nettee-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
val boardApi: String by project
val boardApplication: String by project

dependencies {
api(project(":board:board-application"))
api(project(boardApi))
api(project(boardApplication))
api(project(":rest-client"))
}

This file was deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ์ฝ”๋“œ๋Š” Board ๋ชจ๋“ˆ์ธ๋ฐ, public Board save(Board board) ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ–ˆ์Šต๋‹ˆ๋‹ค.
ํ˜ธ์ถœํ•˜๋ ค๋Š” api์™€ ๊ฐ™์€ ๋ชจ๋“ˆ(=board)์ž…๋‹ˆ๋‹ค.

๊ฐ„๋‹จํ•˜๊ฒŒ ์‚ฌ์šฉ ์˜ˆ์‹œ๋ฅผ ์„ค๋ช…ํ•ด์ฃผ์‹ ๊ฑฐ๋ผ๊ณ  ๋ด๋„ ๋ ๊นŒ์š”?

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package nettee.board.client;

import lombok.RequiredArgsConstructor;
import nettee.board.domain.Board;
import nettee.board.application.port.BoardCommandNetteeClientPort;
import nettee.restclient.NetteeClient;
import nettee.client.request.NetteeRequest;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class BoardCommandNetteeClientAdapter implements BoardCommandNetteeClientPort {

private final NetteeClient netteeClient;

@Override
public Board save(Board board) {
return netteeClient.post(NetteeRequest.<Board>builder()
.domain("board")
.path("/boards")
.body(board)
.responseType(Board.class)
.build()
);
}
}