|
|
|
@ -75,10 +75,10 @@ public class WebClientConfig {
|
|
|
|
|
.clientConnector(new ReactorClientHttpConnector(defaultHttpClient()))
|
|
|
|
|
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 * 1024))
|
|
|
|
|
.exchangeStrategies(defaultExchangeStrategies())
|
|
|
|
|
// .filters(exchangeFilterFunctions -> {
|
|
|
|
|
// exchangeFilterFunctions.add(requestFilter());
|
|
|
|
|
// exchangeFilterFunctions.add(responseFilter());
|
|
|
|
|
// })
|
|
|
|
|
.filters(exchangeFilterFunctions -> {
|
|
|
|
|
exchangeFilterFunctions.add(requestFilter());
|
|
|
|
|
exchangeFilterFunctions.add(responseFilter());
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -136,9 +136,10 @@ public class WebClientConfig {
|
|
|
|
|
private ExchangeFilterFunction requestFilter() {
|
|
|
|
|
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
StringBuilder sb = new StringBuilder("\n>>>>>>>>>> Http Rest Request <<<<<<<<<<<<<\n");
|
|
|
|
|
StringBuilder sb = new StringBuilder("\n>>>>>>>>>> WebClient Http Request <<<<<<<<<<<<<\n");
|
|
|
|
|
sb.append(logMethodAndUrl(clientRequest));
|
|
|
|
|
sb.append(logHeaders(clientRequest));
|
|
|
|
|
sb.append("-------------------------------------------------------");
|
|
|
|
|
log.debug(sb.toString());
|
|
|
|
|
}
|
|
|
|
|
return Mono.just(clientRequest);
|
|
|
|
@ -165,9 +166,10 @@ public class WebClientConfig {
|
|
|
|
|
|
|
|
|
|
if(log.isDebugEnabled()) {
|
|
|
|
|
StringBuilder sb = new StringBuilder(
|
|
|
|
|
"\n>>>>>>>>>> Http Rest Response <<<<<<<<<<<<<\n");
|
|
|
|
|
"\n>>>>>>>>>> WebClient Http Response <<<<<<<<<<<<<\n");
|
|
|
|
|
sb.append(logStatus(clientResponse));
|
|
|
|
|
sb.append(logHeaders(clientResponse));
|
|
|
|
|
sb.append("-------------------------------------------------------");
|
|
|
|
|
log.debug(sb.toString());
|
|
|
|
|
return logBody(clientResponse);
|
|
|
|
|
}
|
|
|
|
@ -193,21 +195,20 @@ public class WebClientConfig {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String logHeaders(ClientResponse response) {
|
|
|
|
|
private static String logHeaders(ClientRequest request) {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
response.headers()
|
|
|
|
|
.asHttpHeaders()
|
|
|
|
|
|
|
|
|
|
request.headers()
|
|
|
|
|
.forEach((name, values) ->
|
|
|
|
|
values.forEach(value -> sb.append(name).append(": ").append(value).append("\n"))
|
|
|
|
|
);
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String logHeaders(ClientRequest request) {
|
|
|
|
|
private static String logHeaders(ClientResponse response) {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
request.headers()
|
|
|
|
|
response.headers()
|
|
|
|
|
.asHttpHeaders()
|
|
|
|
|
.forEach((name, values) ->
|
|
|
|
|
values.forEach(value -> sb.append(name).append(": ").append(value).append("\n"))
|
|
|
|
|
);
|
|
|
|
|