-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/ktb/hackathon/ktbgratitudediary/config/AopConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ktb.hackathon.ktbgratitudediary.config; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
@Slf4j | ||
@Aspect | ||
@Configuration | ||
public class AopConfig { | ||
|
||
@Before("execution(* ktb.hackathon.ktbgratitudediary.controller.*(..))") | ||
public void logBefore(JoinPoint joinPoint) { | ||
// HTTP 요청 정보를 얻기 위해 RequestContextHolder 사용 | ||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | ||
if (attributes != null) { | ||
HttpServletRequest request = attributes.getRequest(); | ||
|
||
String requestURL = request.getRequestURI(); | ||
String methodType = request.getMethod(); | ||
|
||
log.info("HTTP Request - {} / {}", methodType, requestURL); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters