Skip to content

Instantly share code, notes, and snippets.

View lgomezf16's full-sized avatar
๐Ÿ˜Ž
Focusing

Luis Fernando lgomezf16

๐Ÿ˜Ž
Focusing
View GitHub Profile
@lgomezf16
lgomezf16 / HttpRequestLoggingFilter.java
Created July 19, 2022 23:31 — forked from thegeekyasian/HttpRequestLoggingFilter.java
Spring Boot HttpServletRequest Logging Filter. A Request Logging Filter for Spring Boot applications, that allows you to read the request body multiple times. The request body is cached using an overridden HttpServletRequestWrapper. Then a reader that allows the client to read the body multiple times is returned.
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.StreamUtils;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.*;
import java.util.*;