I don't know my approach is correct or not? Also, please let me know if there is any other work-around to achieve this.
Is it possible using WebFilter?
package request.middlewares;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
@Component
public class ResponseTimeCalculator implements WebFilter {
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
// is it possible here?
exchange.getResponse().getHeaders().add("X-Runtime", "10ms");
return chain.filter(exchange);
}
}