|
@@ -0,0 +1,35 @@
|
|
1
|
+package com.yaozhitech.spring5.config;
|
|
2
|
+
|
|
3
|
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
4
|
+import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
5
|
+import org.springframework.context.annotation.Bean;
|
|
6
|
+import org.springframework.context.annotation.Configuration;
|
|
7
|
+import org.springframework.core.Ordered;
|
|
8
|
+import org.springframework.web.server.ServerWebExchange;
|
|
9
|
+
|
|
10
|
+import lombok.extern.slf4j.Slf4j;
|
|
11
|
+import reactor.core.publisher.Mono;
|
|
12
|
+
|
|
13
|
+@Configuration
|
|
14
|
+@Slf4j
|
|
15
|
+public class FilterConfig {
|
|
16
|
+
|
|
17
|
+ @Bean
|
|
18
|
+ public GlobalFilter customFilter() {
|
|
19
|
+ return new CustomGlobalFilter();
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ public class CustomGlobalFilter implements GlobalFilter, Ordered {
|
|
23
|
+
|
|
24
|
+ @Override
|
|
25
|
+ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
|
26
|
+ log.info("custom global filter");
|
|
27
|
+ return chain.filter(exchange);
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ @Override
|
|
31
|
+ public int getOrder() {
|
|
32
|
+ return -1;
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+}
|