Created
March 7, 2021 16:29
-
-
Save njofce/0d33f52059c32b46979e7b04e315a821 to your computer and use it in GitHub Desktop.
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
@Component | |
public class LogRequestFilter implements Filter { | |
@Override | |
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, | |
FilterChain filterChain) throws IOException, ServletException { | |
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; | |
if(Arrays.asList("POST", "PUT").contains(httpRequest.getMethod())) { | |
CustomHttpRequestWrapper requestWrapper = new CustomHttpRequestWrapper(httpRequest); | |
filterChain.doFilter(requestWrapper, servletResponse); | |
return; | |
} | |
filterChain.doFilter(servletRequest, servletResponse); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment