-
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
3 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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) { | ||
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
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