|
@@ -27,6 +27,7 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.codec.HttpMessageReader;
|
|
|
+import org.springframework.http.codec.ServerCodecConfigurer;
|
|
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
|
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
@@ -59,6 +60,9 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
|
@Autowired
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ServerCodecConfigurer serverCodecConfigurer;
|
|
|
+
|
|
|
@Override
|
|
|
public int getOrder() {
|
|
|
return -100;
|
|
@@ -69,6 +73,9 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
|
if (exchange.getAttribute("@manageFilter") != null) {
|
|
|
return chain.filter(exchange);
|
|
|
}
|
|
|
+
|
|
|
+// ServerRequest serverRequest = ServerRequest.create(exchange, serverCodecConfigurer.getReaders());
|
|
|
+
|
|
|
ServerHttpRequest request = exchange.getRequest();
|
|
|
// 请求路径
|
|
|
String requestPath = request.getPath().pathWithinApplication().value();
|
|
@@ -125,7 +132,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private Mono writeBodyLog(ServerWebExchange exchange, GatewayFilterChain chain, GatewayLog gatewayLog) {
|
|
|
- ServerRequest serverRequest = ServerRequest.create(exchange,messageReaders);
|
|
|
+ ServerRequest serverRequest = ServerRequest.create(exchange,serverCodecConfigurer.getReaders());
|
|
|
|
|
|
Mono<String> modifiedBody = serverRequest.bodyToMono(String.class)
|
|
|
.flatMap(body ->{
|