1. 调整 gateway
This commit is contained in:
parent
08f9de153f
commit
45e5e2bc49
|
|
@ -1,5 +1,7 @@
|
||||||
package com.chushang.gateway.config.properties;
|
package com.chushang.gateway.config.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -13,6 +15,8 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
@Configuration
|
@Configuration
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
@ConfigurationProperties(prefix = "security.ignore")
|
@ConfigurationProperties(prefix = "security.ignore")
|
||||||
|
|
@ -23,13 +27,4 @@ public class IgnoreWhiteProperties
|
||||||
*/
|
*/
|
||||||
private List<String> whites = new ArrayList<>();
|
private List<String> whites = new ArrayList<>();
|
||||||
|
|
||||||
public List<String> getWhites()
|
|
||||||
{
|
|
||||||
return whites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWhites(List<String> whites)
|
|
||||||
{
|
|
||||||
this.whites = whites;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,6 @@ import reactor.core.publisher.Mono;
|
||||||
*/
|
*/
|
||||||
public class SentinelFallbackHandler implements WebExceptionHandler
|
public class SentinelFallbackHandler implements WebExceptionHandler
|
||||||
{
|
{
|
||||||
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
|
||||||
{
|
|
||||||
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex)
|
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex)
|
||||||
|
|
@ -34,6 +30,12 @@ public class SentinelFallbackHandler implements WebExceptionHandler
|
||||||
return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));
|
return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
||||||
|
{
|
||||||
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试", 429);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable)
|
private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable)
|
||||||
{
|
{
|
||||||
return GatewayCallbackManager.getBlockHandler().handleRequest(exchange, throwable);
|
return GatewayCallbackManager.getBlockHandler().handleRequest(exchange, throwable);
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,11 @@ spring:
|
||||||
- Path=/api/job/**
|
- Path=/api/job/**
|
||||||
filters:
|
filters:
|
||||||
- StripPrefix=1
|
- StripPrefix=1
|
||||||
#default-filters:
|
# default-filters:
|
||||||
|
# - name: BlackListUrlFilter
|
||||||
|
# args:
|
||||||
|
# blacklistUrl:
|
||||||
|
# - /test
|
||||||
# - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
|
# - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
|
||||||
# # 默认限流
|
# # 默认限流
|
||||||
# - name: RequestRateLimiter
|
# - name: RequestRateLimiter
|
||||||
|
|
@ -79,6 +83,8 @@ spring:
|
||||||
# # 一个请求需要多少令牌 这是为每个请求从桶中获取的令牌数量,默认为1。
|
# # 一个请求需要多少令牌 这是为每个请求从桶中获取的令牌数量,默认为1。
|
||||||
# redis-rate-limiter.requestedTokens: 1
|
# redis-rate-limiter.requestedTokens: 1
|
||||||
# key-resolver: "#{@remoteAddrKeyResolver}"
|
# key-resolver: "#{@remoteAddrKeyResolver}"
|
||||||
|
|
||||||
|
|
||||||
# 安全配置
|
# 安全配置
|
||||||
security:
|
security:
|
||||||
# 验证码
|
# 验证码
|
||||||
|
|
@ -96,7 +102,7 @@ security:
|
||||||
- /auth/logout
|
- /auth/logout
|
||||||
- /auth/login
|
- /auth/login
|
||||||
- /auth/register
|
- /auth/register
|
||||||
- /manager/remote/**
|
- /feign/**
|
||||||
- /demo/**
|
- /demo/**
|
||||||
logging:
|
logging:
|
||||||
config: classpath:logback-nacos.xml
|
config: classpath:logback-nacos.xml
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue