Skip to content

Commit

Permalink
feat: health check 주소 변경 및 로깅 제외
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 committed May 30, 2024
1 parent f9e0535 commit 839d456
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin/system-available")
@RequestMapping("api")
@RequiredArgsConstructor
@Tag(name = "System Check")
public class SystemCheckApi {

private final SystemCheckService systemCheckService;

@PostMapping
@PostMapping("/admin/system-available")
@Operation(summary = "시스템 사용가능 여부 변경하기", description = "시스템 점검 유무를 변경합니다.")
public ApiResponse<Void> changeSystemAvailable(@RequestParam("available") boolean appVersion) {
systemCheckService.changeSystemAvailable(appVersion);
return ApiUtils.success(null);
}

@GetMapping
@GetMapping("/system-available")
@Operation(summary = "시스템 사용가능 여부 체크", description = "현재 서버의 상태를 점검합니다.")
public ApiResponse<HealthCheckResponse> healthCheck() {
HealthCheckDto healthCheckDto = systemCheckService.healthCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui/**"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui.html"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/api-docs/**"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/api/admin/system-available"),
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/api/system-available"),
AntPathRequestMatcher.antMatcher("/actu/**")
).permitAll()
.requestMatchers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
public class LoggingFilter extends OncePerRequestFilter {

private static void logRequest(HttpServletRequest request) {
if (request.getRequestURI() != null && request.getRequestURI().contains("/prometheus")) {
if (request.getRequestURI() != null &&
(request.getRequestURI().contains("/prometheus") || request.getRequestURI().equals("/api/system-available"))) {
return;
}
String queryString = request.getQueryString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void success_1() throws Exception {
appVersionRepository.save(new AppVersion(OperationSystem.IOS, "1.0.2"));

// expect
MvcResult mvcResult = mockMvc.perform(get("/api/admin/system-available"))
MvcResult mvcResult = mockMvc.perform(get("/api/system-available"))
.andExpect(status().isOk())
.andDo(print())
.andReturn();
Expand All @@ -135,7 +135,7 @@ void success_2() throws Exception {
appVersionRepository.save(new AppVersion(OperationSystem.ANDROID, "1.0.1"));

// expect
MvcResult mvcResult = mockMvc.perform(get("/api/admin/system-available"))
MvcResult mvcResult = mockMvc.perform(get("/api/system-available"))
.andExpect(status().isOk())
.andDo(print())
.andReturn();
Expand Down

0 comments on commit 839d456

Please sign in to comment.