Created
April 5, 2018 07:05
-
-
Save nattaphonjeamjit/7a87072c468c40839ec14f10822e37c5 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
import org.springframework.web.filter.OncePerRequestFilter; | |
import java.util.UUID; | |
@Configuration | |
public class LogIPAddressFilter extends OncePerRequestFilter { | |
private static final String KEY = "X-IP-ADDRESS"; | |
@Override | |
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { | |
ThreadContext.put(KEY, request.getRemoteAddr()); | |
chain.doFilter(request, response); | |
ThreadContext.clearAll(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment