|
|
@ -80,15 +80,16 @@ public class IndexFilter implements WebFilter { |
|
|
|
if (request.getMethod() == HttpMethod.POST) { |
|
|
|
if (request.getMethod() == HttpMethod.POST) { |
|
|
|
ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange); |
|
|
|
ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange); |
|
|
|
// 读取请求体中的内容
|
|
|
|
// 读取请求体中的内容
|
|
|
|
Mono<?> modifiedBody = serverRequest.bodyToMono(String.class) |
|
|
|
Mono<?> modifiedBody = serverRequest.bodyToMono(byte[].class) |
|
|
|
.flatMap(body -> { |
|
|
|
.flatMap(data -> { |
|
|
|
|
|
|
|
String body = new String(data, SopConstants.CHARSET_UTF8); |
|
|
|
// 构建ApiParam
|
|
|
|
// 构建ApiParam
|
|
|
|
ApiParam apiParam = ServerWebExchangeUtil.getApiParam(exchange, body); |
|
|
|
ApiParam apiParam = ServerWebExchangeUtil.getApiParam(exchange, body); |
|
|
|
// 签名验证
|
|
|
|
// 签名验证
|
|
|
|
doValidate(exchange, apiParam); |
|
|
|
doValidate(exchange, apiParam); |
|
|
|
return Mono.just(body); |
|
|
|
return Mono.just(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
BodyInserter bodyInserter = BodyInserters.fromPublisher(modifiedBody, (Class) String.class); |
|
|
|
BodyInserter bodyInserter = BodyInserters.fromPublisher(modifiedBody, (Class)byte[].class); |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
headers.putAll(exchange.getRequest().getHeaders()); |
|
|
|
headers.putAll(exchange.getRequest().getHeaders()); |
|
|
|
|
|
|
|
|
|
|
@ -130,7 +131,9 @@ public class IndexFilter implements WebFilter { |
|
|
|
validator.validate(apiParam); |
|
|
|
validator.validate(apiParam); |
|
|
|
this.afterValidate(exchange, apiParam); |
|
|
|
this.afterValidate(exchange, apiParam); |
|
|
|
} catch (ApiException e) { |
|
|
|
} catch (ApiException e) { |
|
|
|
log.error("验证失败,ip:{}, params:{}, errorMsg:{}", apiParam.fetchIp(), apiParam.toJSONString(), e.getMessage()); |
|
|
|
log.error("验证失败,url:{}, ip:{}, params:{}, errorMsg:{}", |
|
|
|
|
|
|
|
exchange.getRequest().getURI().toString(), |
|
|
|
|
|
|
|
apiParam.fetchIp(), apiParam.toJSONString(), e.getMessage()); |
|
|
|
ServerWebExchangeUtil.setThrowable(exchange, e); |
|
|
|
ServerWebExchangeUtil.setThrowable(exchange, e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|