Browse Source

!39 修复sentinel流量告警无提示

Merge pull request !39 from 9527/master
tags/v2.5.0
若依 4 years ago committed by Gitee
parent
commit
0546504cae
  1. 4
      ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java

4
ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java

@ -12,7 +12,7 @@ import reactor.core.publisher.Mono; @@ -12,7 +12,7 @@ import reactor.core.publisher.Mono;
/**
* 自定义限流异常处理
*
*
* @author ruoyi
*/
public class SentinelFallbackHandler implements WebExceptionHandler
@ -21,7 +21,7 @@ public class SentinelFallbackHandler implements WebExceptionHandler @@ -21,7 +21,7 @@ public class SentinelFallbackHandler implements WebExceptionHandler
{
ServerHttpResponse serverHttpResponse = exchange.getResponse();
serverHttpResponse.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
byte[] datas = "{\"status\":429,\"message\":\"请求超过最大数,请稍后再试\"}".getBytes(StandardCharsets.UTF_8);
byte[] datas = "{\"code\":429,\"msg\":\"请求超过最大数,请稍后再试\"}".getBytes(StandardCharsets.UTF_8);
DataBuffer buffer = serverHttpResponse.bufferFactory().wrap(datas);
return serverHttpResponse.writeWith(Mono.just(buffer));
}

Loading…
Cancel
Save