Merge branch 'master' into eureka

eureka
tanghc 4 years ago
commit 31e23971a1
  1. 4
      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.gateway.ServerWebExchangeUtil;
import com.gitee.sop.gatewaycommon.message.ErrorEnum; import com.gitee.sop.gatewaycommon.message.ErrorEnum;
import com.gitee.sop.gatewaycommon.result.ResultExecutor; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
@ -28,6 +30,7 @@ public class GatewayController {
// 合并微服务传递过来的结果,变成最终结果 // 合并微服务传递过来的结果,变成最终结果
ResultExecutor<ServerWebExchange, String> resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor(); ResultExecutor<ServerWebExchange, String> resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor();
String gatewayResult = resultExecutor.buildErrorResult(exchange, throwable); String gatewayResult = resultExecutor.buildErrorResult(exchange, throwable);
exchange.getResponse().getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
return Mono.just(gatewayResult); return Mono.just(gatewayResult);
} }
@ -36,6 +39,7 @@ public class GatewayController {
ApiException exception = ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException(); ApiException exception = ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException();
ResultExecutor<ServerWebExchange, String> resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor(); ResultExecutor<ServerWebExchange, String> resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor();
String gatewayResult = resultExecutor.buildErrorResult(exchange, exception); String gatewayResult = resultExecutor.buildErrorResult(exchange, exception);
exchange.getResponse().getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
return Mono.just(gatewayResult); return Mono.just(gatewayResult);
} }

Loading…
Cancel
Save