Example usage for org.springframework.http.server.reactive ServerHttpResponse beforeCommit

List of usage examples for org.springframework.http.server.reactive ServerHttpResponse beforeCommit

Introduction

In this page you can find the example usage for org.springframework.http.server.reactive ServerHttpResponse beforeCommit.

Prototype

void beforeCommit(Supplier<? extends Mono<Void>> action);

Source Link

Document

Register an action to apply just before the HttpOutputMessage is committed.

Usage

From source file:org.springframework.cloud.gateway.filter.GatewayMetricsFilter.java

private void endTimerRespectingCommit(ServerWebExchange exchange, Sample sample) {

    ServerHttpResponse response = exchange.getResponse();
    if (response.isCommitted()) {
        endTimerInner(exchange, sample);
    } else {//from  ww w.j  av a  2s.  co m
        response.beforeCommit(() -> {
            endTimerInner(exchange, sample);
            return Mono.empty();
        });
    }
}