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 #45 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 a426b99 + 12d75b2 commit dc656c8
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/main/java/works/weave/socks/orders/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package works.weave.socks.orders.config;

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.orders.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 dc656c8

Please # to comment.