Merge pull request #4446 from eugenp/custom-filter-update

Custom filter update
This commit is contained in:
Loredana Crusoveanu 2018-06-14 13:12:07 +03:00 committed by GitHub
commit f4dca016a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.bootcustomfilters;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baeldung.bootcustomfilters.filters.RequestResponseLoggingFilter;
@Configuration
public class FilterConfig {
// uncomment this and comment the @Component in the filter class definition to register only for a url pattern
// @Bean
public FilterRegistrationBean<RequestResponseLoggingFilter> loggingFilter() {
FilterRegistrationBean<RequestResponseLoggingFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new RequestResponseLoggingFilter());
registrationBean.addUrlPatterns("/users/*");
return registrationBean;
}
}