Skip to content

Commit b60aaf8

Browse files
committed
update api-gateway
1 parent 8f0ac94 commit b60aaf8

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

api-gateway/src/main/java/com/macro/cloud/config/GatewayConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Created by macro on 2019/9/24.
1010
*/
11-
@Configuration
11+
//@Configuration
1212
public class GatewayConfig {
1313

1414
@Bean

api-gateway/src/main/java/com/macro/cloud/config/RedisRateLimiterConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
*/
1111
@Configuration
1212
public class RedisRateLimiterConfig {
13-
@Bean
14-
KeyResolver userKeyResolver() {
15-
return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("username"));
16-
}
13+
// @Bean
14+
// KeyResolver userKeyResolver() {
15+
// return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("username"));
16+
// }
1717

1818
@Bean
1919
public KeyResolver ipKeyResolver() {

api-gateway/src/main/resources/application-eureka.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ spring:
77
gateway:
88
discovery:
99
locator:
10-
enabled: true
11-
lower-case-service-id: true
10+
enabled: true #开启从注册中心动态创建路由的功能
11+
lower-case-service-id: true #使用小写服务名,默认是大写
1212
eureka:
1313
client:
1414
service-url:
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
server:
22
port: 9201
33
spring:
4+
redis:
5+
host: localhost
6+
port: 6379
47
cloud:
58
gateway:
69
routes:
7-
- id: retry_test
10+
- id: retry_route
811
uri: http://localhost:8201
912
predicates:
1013
- Method=GET
1114
filters:
1215
- name: Retry
1316
args:
14-
retries: 1
15-
statuses: BAD_GATEWAY
17+
retries: 1 #需要进行重试的次数
18+
statuses: BAD_GATEWAY #返回哪个状态码需要进行重试,返回状态码为5XX进行重试
1619
backoff:
1720
firstBackoff: 10ms
1821
maxBackoff: 50ms
1922
factor: 2
2023
basedOnPreviousValue: false
21-
2224
logging:
2325
level:
2426
org.springframework.cloud.gateway: debug

0 commit comments

Comments
 (0)