Spring Cloud Gateway => Read a Response Body and transform to a JSON object

Viewed 167

I'm using Spring Cloud Gateway and I am stuck at doing, what I think, a simple thing.

I want to read a response Body and transform it to a Json Object so that I can read the value that I want.

I can extract cookies, headers, status BUT not the body.

So far my code is like that (in a custom filter) :

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        return chain.filter(exchange).then(Mono.defer(() -> {
            ServerHttpResponse response = exchange.getResponse();
            // Get the response body and transform it to a Json Object

Do U guys have an idea ?

Thank you very much.

0 Answers
Related