pull/1/head
tanghc 5 years ago
parent 26f7d2843e
commit c5c43b3be4
  1. 6
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ParameterFormatterFilter.java
  2. 6
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreParameterFormatterFilter.java

@ -21,7 +21,7 @@ import static com.gitee.sop.gatewaycommon.gateway.filter.Orders.PARAMETER_FORMAT
public class ParameterFormatterFilter implements GlobalFilter, Ordered {
@Autowired(required = false)
private ParameterFormatter sopParameterFormatter;
private ParameterFormatter parameterFormatter;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
@ -30,11 +30,11 @@ public class ParameterFormatterFilter implements GlobalFilter, Ordered {
return chain.filter(exchange);
}
// 校验成功后进行参数转换
if (sopParameterFormatter != null) {
if (parameterFormatter != null) {
ServerWebExchange formatExchange = ServerWebExchangeUtil.format(
exchange
, apiParam
, sopParameterFormatter::format
, parameterFormatter::format
, httpHeaders -> httpHeaders.set(ParamNames.HEADER_VERSION_NAME, apiParam.fetchVersion()));
return chain.filter(formatExchange);
}

@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class PreParameterFormatterFilter extends BaseZuulFilter {
@Autowired(required = false)
private ParameterFormatter sopParameterFormatter;
private ParameterFormatter parameterFormatter;
@Override
protected FilterType getFilterType() {
@ -33,8 +33,8 @@ public class PreParameterFormatterFilter extends BaseZuulFilter {
protected Object doRun(RequestContext requestContext) throws ZuulException {
ApiParam apiParam = ZuulContext.getApiParam();
// 校验成功后进行参数转换
if (sopParameterFormatter != null) {
ZuulParameterUtil.format(apiParam, sopParameterFormatter::format);
if (parameterFormatter != null) {
ZuulParameterUtil.format(apiParam, parameterFormatter::format);
requestContext.addZuulRequestHeader(ParamNames.HEADER_VERSION_NAME, apiParam.fetchVersion());
}
return null;

Loading…
Cancel
Save