Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:innovationacademy-kr/42cabi into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
junyoung2015 committed Nov 27, 2023
2 parents 4da913e + d4006f2 commit 4ebf8cc
Showing 1 changed file with 33 additions and 0 deletions.
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);
}


}

0 comments on commit 4ebf8cc

Please sign in to comment.