小编Mar*_*ulc的帖子

WebClient - how to get request body?

I've started using WebClient and I'm adding logging of request/response and I'm using filter method when constructing WebClient:

WebClient.builder()
    .baseUrl(properties.getEndpoint())
    .filter((request, next) -> {
        // logging
        request.body()
    })
    .build();
Run Code Online (Sandbox Code Playgroud)

I'm able to access url, http method, headers but I've a problem with getting raw request body as body() method of request returns BodyInserter (BodyInserter<?, ? super ClientHttpRequest> body().

How to convert BodyInserter to String representation of request body? Alternatively, how to properly log whole request/response while also being …

java spring spring-webflux

7
推荐指数
2
解决办法
5630
查看次数

标签 统计

java ×1

spring ×1

spring-webflux ×1