|
|
|
@ -80,15 +80,16 @@ public class IndexFilter implements WebFilter { |
|
|
|
|
if (request.getMethod() == HttpMethod.POST) { |
|
|
|
|
ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange); |
|
|
|
|
// 读取请求体中的内容
|
|
|
|
|
Mono<?> modifiedBody = serverRequest.bodyToMono(String.class) |
|
|
|
|
.flatMap(body -> { |
|
|
|
|
Mono<?> modifiedBody = serverRequest.bodyToMono(byte[].class) |
|
|
|
|
.flatMap(data -> { |
|
|
|
|
String body = new String(data, SopConstants.CHARSET_UTF8); |
|
|
|
|
// 构建ApiParam
|
|
|
|
|
ApiParam apiParam = ServerWebExchangeUtil.getApiParam(exchange, body); |
|
|
|
|
// 签名验证
|
|
|
|
|
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(); |
|
|
|
|
headers.putAll(exchange.getRequest().getHeaders()); |
|
|
|
|
|
|
|
|
@ -130,7 +131,9 @@ public class IndexFilter implements WebFilter { |
|
|
|
|
validator.validate(apiParam); |
|
|
|
|
this.afterValidate(exchange, apiParam); |
|
|
|
|
} 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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|