From d94e008533bfbf23257f9dfe937d831059d7054e Mon Sep 17 00:00:00 2001 From: Due <48638700+Due-IT@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:12:03 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20=EC=9A=94=EC=B2=AD=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=A1=9C=EA=B9=85=20(#44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(HeatlCheck) : 상태 및 업데이트 확인을 위한 컨트롤러를 추가한다 * feat(SecurityConfig) : heatlcheck 컨트롤러는 권한 없이 접근을 허용 * refactor(HealthCheckController) : EOL 추가 * fix(WebConfig) : 요청 헤더 와일드카드 적용 * feat(RequestLoggingInterceptor) : 요청을 받는 가장 앞에서 요청정보를 로깅한다 --- .../wabi/common/RequestLoggingInterceptor.kt | 18 ++++++++++++++++++ .../com/wap/wabi/common/config/WebConfig.kt | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 wabi/src/main/kotlin/com/wap/wabi/common/RequestLoggingInterceptor.kt diff --git a/wabi/src/main/kotlin/com/wap/wabi/common/RequestLoggingInterceptor.kt b/wabi/src/main/kotlin/com/wap/wabi/common/RequestLoggingInterceptor.kt new file mode 100644 index 0000000..ebef885 --- /dev/null +++ b/wabi/src/main/kotlin/com/wap/wabi/common/RequestLoggingInterceptor.kt @@ -0,0 +1,18 @@ +package com.wap.wabi.common + +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Component +import org.springframework.web.servlet.HandlerInterceptor + + +@Component +class RequestLoggingInterceptor : HandlerInterceptor { + private val logger = LoggerFactory.getLogger(RequestLoggingInterceptor::class.java) + + override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean { + logger.info("Request received from" + request.remoteAddr + "to" + request.requestURI) + return true + } +} diff --git a/wabi/src/main/kotlin/com/wap/wabi/common/config/WebConfig.kt b/wabi/src/main/kotlin/com/wap/wabi/common/config/WebConfig.kt index 282de3c..a1a5313 100644 --- a/wabi/src/main/kotlin/com/wap/wabi/common/config/WebConfig.kt +++ b/wabi/src/main/kotlin/com/wap/wabi/common/config/WebConfig.kt @@ -1,11 +1,13 @@ package com.wap.wabi.common.config +import com.wap.wabi.common.RequestLoggingInterceptor import org.springframework.context.annotation.Configuration import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.InterceptorRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration -class WebConfig : WebMvcConfigurer { +class WebConfig(private val requestLoggingInterceptor: RequestLoggingInterceptor) : WebMvcConfigurer { override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") .allowedOrigins( @@ -18,4 +20,8 @@ class WebConfig : WebMvcConfigurer { .allowedHeaders("*") .allowCredentials(true); } + + override fun addInterceptors(registry: InterceptorRegistry) { + registry.addInterceptor(requestLoggingInterceptor).addPathPatterns("/**") + } } \ No newline at end of file