Skip to content

Commit

Permalink
update api-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
macrozheng committed Oct 27, 2019
1 parent 8f0ac94 commit b60aaf8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Created by macro on 2019/9/24.
*/
@Configuration
//@Configuration
public class GatewayConfig {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/
@Configuration
public class RedisRateLimiterConfig {
@Bean
KeyResolver userKeyResolver() {
return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("username"));
}
// @Bean
// KeyResolver userKeyResolver() {
// return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("username"));
// }

@Bean
public KeyResolver ipKeyResolver() {
Expand Down
4 changes: 2 additions & 2 deletions api-gateway/src/main/resources/application-eureka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ spring:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
enabled: true #开启从注册中心动态创建路由的功能
lower-case-service-id: true #使用小写服务名,默认是大写
eureka:
client:
service-url:
Expand Down
10 changes: 6 additions & 4 deletions api-gateway/src/main/resources/application-filter.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
server:
port: 9201
spring:
redis:
host: localhost
port: 6379
cloud:
gateway:
routes:
- id: retry_test
- id: retry_route
uri: http://localhost:8201
predicates:
- Method=GET
filters:
- name: Retry
args:
retries: 1
statuses: BAD_GATEWAY
retries: 1 #需要进行重试的次数
statuses: BAD_GATEWAY #返回哪个状态码需要进行重试,返回状态码为5XX进行重试
backoff:
firstBackoff: 10ms
maxBackoff: 50ms
factor: 2
basedOnPreviousValue: false

logging:
level:
org.springframework.cloud.gateway: debug

0 comments on commit b60aaf8

Please sign in to comment.