I would like to get request body, so I decided to implements HttpResponseInterceptor interface. How to do it properly?
public class CustomHttpInterceptor implements org.apache.http.HttpRequestInterceptorHttpRequestInterceptor {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
}
}
Should I create CustomHttpInterceptor as a bean? How to add it too be visible for Spring?
You can also use the spring's provided HandlerInterceptorAdapter
implement the interface and add a Config class that implements WebMvcConfigurer
which has a method
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoggerInterceptor());
}
You can find more details on https://www.baeldung.com/spring-mvc-handlerinterceptor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.