diff --git a/changelog.md b/changelog.md index 51ac3c18..03f668dd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # changelog +## 3.2.1 + +- 强化RouteInterceptorContext,可获取微服务信息 + ## 3.2.0 - 使用alibaba cloud diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java index 62cbb64b..795e9e25 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java @@ -150,6 +150,11 @@ public abstract class BaseExecutorAdapter implements ResultExecutor } ErrorMeta errorMeta = errorEnum.getErrorMeta(); JSONObject responseData = JSON.parseObject(serviceResult); + ApiParam apiParam = this.getApiParam(request); + if (apiParam != null) { + // 全局请求id,方便追踪定位 + responseData.put("request_id", apiParam.fetchRequestId()); + } responseData.put(GATEWAY_CODE_NAME, errorMeta.getCode()); responseData.put(GATEWAY_MSG_NAME, errorMeta.getError(getLocale(request)).getMsg()); return responseData; @@ -185,8 +190,6 @@ public abstract class BaseExecutorAdapter implements ResultExecutor params = new ApiParam(); params.setName("error"); } - // 全局请求id,方便追踪定位 - finalData.put("request_id", params.fetchRequestId()); ApiConfig apiConfig = ApiConfig.getInstance(); // 点换成下划线 DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder();