resttemplate 호출 시 주울 호출

This commit is contained in:
juhyun10
2020-09-06 20:59:22 +09:00
parent ab22833e05
commit 3e73cc3ac8
2 changed files with 14 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
package com.assu.cloud.memberservice.client;
import com.assu.cloud.memberservice.config.CustomConfig;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@@ -9,11 +10,15 @@ import org.springframework.web.client.RestTemplate;
public class EventRestTemplateClient {
RestTemplate restTemplate;
CustomConfig customConfig;
public EventRestTemplateClient(RestTemplate restTemplate) {
public EventRestTemplateClient(RestTemplate restTemplate, CustomConfig customConfig) {
this.restTemplate = restTemplate;
this.customConfig = customConfig;
}
String URL_PREFIX = "/api/evt/event/"; // 이벤트 서비스의 주울 라우팅경로와 이벤트 클래스 주소
public String gift(String name) {
/*ResponseEntity<EventGift> restExchange =
restTemplate.exchange(
@@ -23,7 +28,7 @@ public class EventRestTemplateClient {
);*/
ResponseEntity<String> restExchange =
restTemplate.exchange(
"http://event-service/event/gift/{name}",
"http://" + customConfig.getServiceIdZuul() + URL_PREFIX + "gift/{name}", // http://localhost:5555/api/mb/member/gift/flower
HttpMethod.GET,
null, String.class, name
);

View File

@@ -10,7 +10,14 @@ public class CustomConfig {
@Value("${your.name}")
private String yourName;
@Value("${service.id.zuul}")
private String serviceIdZuul;
public String getYourName() {
return yourName;
}
public String getServiceIdZuul() {
return serviceIdZuul;
}
}