From 2243a93f5b7dfb2a7b48dccada2ddfa846301cb8 Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 10 Nov 2020 19:53:07 +0800 Subject: [PATCH 1/2] 4.2.0 --- .../gatewaycommon/gateway/controller/GatewayController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java index 8836ad13..44590fa8 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java @@ -5,6 +5,8 @@ import com.gitee.sop.gatewaycommon.exception.ApiException; import com.gitee.sop.gatewaycommon.gateway.ServerWebExchangeUtil; import com.gitee.sop.gatewaycommon.message.ErrorEnum; import com.gitee.sop.gatewaycommon.result.ResultExecutor; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ServerWebExchange; @@ -28,6 +30,7 @@ public class GatewayController { // 合并微服务传递过来的结果,变成最终结果 ResultExecutor resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor(); String gatewayResult = resultExecutor.buildErrorResult(exchange, throwable); + exchange.getResponse().getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); return Mono.just(gatewayResult); } From 13e30c87b6eae437700c92cc549b6990c16d0d32 Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 10 Nov 2020 19:53:24 +0800 Subject: [PATCH 2/2] 4.2.0 --- .../sop/gatewaycommon/gateway/controller/GatewayController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java index 44590fa8..6b5ba31a 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/controller/GatewayController.java @@ -39,6 +39,7 @@ public class GatewayController { ApiException exception = ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException(); ResultExecutor resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor(); String gatewayResult = resultExecutor.buildErrorResult(exchange, exception); + exchange.getResponse().getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); return Mono.just(gatewayResult); }