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

Commit 5c127b3

Browse files
author
Phil Winder
authored
Merge pull request #21 from microservices-demo/fix/http-middleware
Another way to add a http middleware that works with spring boot.
2 parents 92841f3 + 5c7df86 commit 5c127b3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
package works.weave.socks.shipping.configuration;
22

3-
import org.springframework.beans.factory.annotation.Autowired;
43
import org.springframework.context.annotation.Bean;
54
import org.springframework.context.annotation.Configuration;
6-
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
7-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
5+
import org.springframework.web.servlet.handler.MappedInterceptor;
86
import works.weave.socks.shipping.middleware.HTTPMonitoringInterceptor;
97

108
@Configuration
11-
public class WebMvcConfig extends WebMvcConfigurerAdapter {
12-
@Autowired
13-
private HTTPMonitoringInterceptor httpMonitoringInterceptor;
14-
9+
public class WebMvcConfig {
1510
@Bean
1611
HTTPMonitoringInterceptor httpMonitoringInterceptor() {
1712
return new HTTPMonitoringInterceptor();
1813
}
1914

20-
@Override
21-
public void addInterceptors(InterceptorRegistry registry) {
22-
registry.addInterceptor(httpMonitoringInterceptor)
23-
.addPathPatterns("/**");
15+
@Bean
16+
public MappedInterceptor myMappedInterceptor(HTTPMonitoringInterceptor interceptor) {
17+
return new MappedInterceptor(new String[]{"/**"}, interceptor);
2418
}
2519
}

0 commit comments

Comments
 (0)