mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-13 05:59:01 +08:00
upgrade(core bom): springboot 3.3.2 &spring cloud 2023.0.3
- springboot 3.3.2 - spring cloud 2023.0.3 - spring cloud alibaba 2023.0.1.2 - spring boot admin 3.3.2 - hutool 5.8.29 (cherry picked from commit ba8fc7e8d3cfc15725db50e161e8db17d267df89)
This commit is contained in:
1 parent
ad0c7b87b1
commit
1359415965
3 files changed
+22
-15
No files matched your search
+2
-2
@@ -18,8 +18,8 @@
|
||||
package com.pig4cloud.pigx.common.sentinel;
|
||||
|
||||
import com.alibaba.cloud.sentinel.feign.SentinelFeignAutoConfiguration;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.RequestOriginParser;
|
||||
import com.pig4cloud.pigx.common.sentinel.feign.PigxSentinelFeign;
|
||||
import com.pig4cloud.pigx.common.sentinel.handle.GlobalBizExceptionHandler;
|
||||
import com.pig4cloud.pigx.common.sentinel.handle.PigxUrlBlockHandler;
|
||||
|
||||
+19
-12
@@ -18,14 +18,13 @@
|
||||
package com.pig4cloud.pigx.common.sentinel.handle;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler;
|
||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@@ -36,12 +35,20 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
@Slf4j
|
||||
public class PigxUrlBlockHandler implements BlockExceptionHandler {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
|
||||
log.error("sentinel 降级 资源名称{}", e.getRule().getResource(), e);
|
||||
response.setContentType("application/json");
|
||||
response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
|
||||
response.getWriter().print(JSONUtil.toJsonStr(R.failed(e.getMessage())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the request when blocked.
|
||||
*
|
||||
* @param request Servlet request
|
||||
* @param response Servlet response
|
||||
* @param resourceName resource name
|
||||
* @param e the block exception
|
||||
* @throws Exception users may throw out the BlockException or other error occurs
|
||||
*/
|
||||
@Override
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response, String resourceName, BlockException e) throws Exception {
|
||||
log.error("sentinel 降级 资源名称{}", resourceName, e);
|
||||
response.setContentType("application/json");
|
||||
response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
|
||||
response.getWriter().print(JSONUtil.toJsonStr(R.failed(e.getMessage())));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,8 +17,8 @@
|
||||
|
||||
package com.pig4cloud.pigx.common.sentinel.parser;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.RequestOriginParser;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user