fix: RateLimitConfig添加@Primary注解解决多KeyResolver冲突
This commit is contained in:
parent
281bbc992d
commit
5d4cdd5c33
@ -3,6 +3,7 @@ package com.fundplatform.gateway.config;
|
|||||||
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
|
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,9 +13,10 @@ import reactor.core.publisher.Mono;
|
|||||||
public class RateLimitConfig {
|
public class RateLimitConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于IP的限流Key解析器
|
* 基于IP的限流Key解析器 (默认)
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@Primary
|
||||||
public KeyResolver ipKeyResolver() {
|
public KeyResolver ipKeyResolver() {
|
||||||
return exchange -> {
|
return exchange -> {
|
||||||
String ip = exchange.getRequest().getRemoteAddress() != null
|
String ip = exchange.getRequest().getRemoteAddress() != null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user