-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:innovationacademy-kr/42cabi into dev
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/org/ftclub/cabinet/utils/TimeResponseFilter.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,33 @@ | ||
package org.ftclub.cabinet.utils; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
import javax.servlet.Filter; | ||
import javax.servlet.FilterChain; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.annotation.WebFilter; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* 모든 응답에 X-Current-Time 헤더를 추가하는 필터 | ||
*/ | ||
@Component | ||
@WebFilter("/*") | ||
public class TimeResponseFilter implements Filter { | ||
|
||
@Override | ||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | ||
throws IOException, ServletException { | ||
|
||
String currentTime = LocalDateTime.now().toString(); | ||
HttpServletResponse httpServletResponse = (HttpServletResponse) response; | ||
httpServletResponse.addHeader("X-Current-Time", currentTime); | ||
chain.doFilter(request, response); | ||
} | ||
|
||
|
||
} |