Skip to content

Commit adac0de

Browse files
authored
Merge branch 'develop' into feature/#35-API-Response
2 parents 70d4add + 15e0731 commit adac0de

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

backend/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ dependencies {
5454
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
5555
testImplementation 'com.h2database:h2' //테스트 환경 h2 DB
5656
testImplementation 'org.assertj:assertj-core:3.24.2' //테스트 검증을 위한 AssertJ 라이브러리
57+
58+
implementation 'org.springframework.boot:spring-boot-starter-actuator' // Actuator 기능으로 서버 및 애플리케이션 상태 확인
59+
runtimeOnly 'mysql:mysql-connector-java:8.0.33'
5760
}
5861

5962
tasks.named('test') {

backend/src/main/java/com/postdm/backend/global/config/SecurityConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
4949
.requestMatchers("/api/v1/auth/**").permitAll() // /api/v1/auth로 시작하는 경로는 모두 허용(회원가입, 로그인 등)
5050
.requestMatchers("/api/v1/email/**").permitAll()
5151
.requestMatchers("/api/v1/member/**").permitAll()
52+
.requestMatchers("/api/v1/ping**").permitAll() // /ping api 모두 허용
53+
.requestMatchers("/actuator/health").hasRole("ADMIN") // Actuator 헬스 체크 결과는 관리자만 접근 가능
54+
.requestMatchers("/actuator/**").denyAll() // 다른 Actuator 엔드포인트는 차단
5255
.requestMatchers("/api/v1/estimates/**").hasAnyRole("MEMBER", "ADMIN") // 견적서 API는 MEMBER와 ADMIN만 접근 가능
5356
.anyRequest().authenticated() // 이외의 경로는 인증을 필요로함.
5457
);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.postdm.backend.global.controller;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
5+
import io.swagger.v3.oas.annotations.tags.Tag;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
import java.util.Collections;
12+
import java.util.Map;
13+
14+
@RestController
15+
@Tag(name = "Ping Check", description = "단순 서버 연결 상태 확인 API")
16+
@RequestMapping("/api/v1")
17+
public class PingController {
18+
19+
@Operation(summary = "서버 상태 체크", description = "서버가 정상적으로 동작하는지 확인하는 API입니다.")
20+
@ApiResponse(responseCode = "200", description = "서버 정상 작동. 응답: text/plain (pong)")
21+
@GetMapping("/ping")
22+
public ResponseEntity<Map<String, String>> ping() {
23+
return ResponseEntity.ok(Collections.singletonMap("message", "pong"));
24+
}
25+
}

backend/src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ springdoc:
1818
enabled: true
1919
cache:
2020
disabled: true
21-
override-with-generic-response: false
21+
override-with-generic-response: false
22+
23+
management:
24+
endpoint:
25+
health:
26+
show-details: when_authorized

0 commit comments

Comments
 (0)