Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from microservices-demo/fix/http-middleware
Browse files Browse the repository at this point in the history
Another way to add a http middleware that works with spring boot.
  • Loading branch information
Phil Winder authored Mar 15, 2017
2 parents 92841f3 + 5c7df86 commit 5c127b3
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package works.weave.socks.shipping.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.shipping.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 comments on commit 5c127b3

Please sign in to comment.