Skip to content
Snippets Groups Projects
Commit 1ef22f59 authored by Phil Winder's avatar Phil Winder Committed by GitHub
Browse files

Merge pull request #28 from microservices-demo/fix/http-middleware

Another way to add a http middleware that works with spring boot.
parents bade28b7 abf20112
No related branches found
No related tags found
No related merge requests found
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment