Commit abf20112 authored by Phil Winder's avatar Phil Winder
Browse files

Another way to add a http middleware that works with spring boot.

parent bade28b7
package works.weave.socks.cart.configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.handler.MappedInterceptor;
import works.weave.socks.cart.middleware.HTTPMonitoringInterceptor;
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private HTTPMonitoringInterceptor httpMonitoringInterceptor;
public class WebMvcConfig {
@Bean
HTTPMonitoringInterceptor httpMonitoringInterceptor() {
return new HTTPMonitoringInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(httpMonitoringInterceptor)
.addPathPatterns("/**");
@Bean
public MappedInterceptor myMappedInterceptor(HTTPMonitoringInterceptor interceptor) {
return new MappedInterceptor(new String[]{"/**"}, interceptor);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment