Skip to content

Commit dd16e25

Browse files
committed
[FIX] 하드코딩된 주소를 제거하고, application.yml 파일의 설정을 읽어오도록 코드를 수정
1 parent d37459f commit dd16e25

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/org/terning/fcm/application/FcmPushScheduler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.Map;
55
import lombok.RequiredArgsConstructor;
66
import lombok.extern.slf4j.Slf4j;
7+
8+
import org.springframework.beans.factory.annotation.Value;
79
import org.springframework.http.HttpEntity;
810
import org.springframework.http.HttpHeaders;
911
import org.springframework.http.MediaType;
@@ -18,14 +20,15 @@ public class FcmPushScheduler {
1820

1921
private final RestTemplate restTemplate;
2022

21-
private static final String BASE_URL = "http://13.209.210.3/api/v1";
23+
@Value("${ops.server.url}/api/v1")
24+
private String base_url;
2225

2326
private void callPost(String path) {
2427
HttpHeaders headers = new HttpHeaders();
2528
headers.setContentType(MediaType.APPLICATION_JSON);
2629
HttpEntity<Void> entity = new HttpEntity<>(headers);
2730

28-
String url = BASE_URL + path;
31+
String url = base_url + path;
2932
try {
3033
restTemplate.postForEntity(url, entity, String.class);
3134
log.info("POST 요청 성공: {}", url);
@@ -42,7 +45,7 @@ private void callPost(String path, String template) {
4245
bM.put("template", template);
4346

4447
HttpEntity<Map<String, String>> entity = new HttpEntity<>(bM, headers);
45-
String url = BASE_URL + path;
48+
String url = base_url + path;
4649

4750
try {
4851
restTemplate.postForEntity(url, entity, String.class);
@@ -53,7 +56,7 @@ private void callPost(String path, String template) {
5356
}
5457

5558
private void callGet(String path) {
56-
String url = BASE_URL + path;
59+
String url = base_url + path;
5760
try {
5861
restTemplate.getForEntity(url, String.class);
5962
log.info("GET 요청 성공: {}", url);

0 commit comments

Comments
 (0)