Search in sources :

Example 1 with RewriteBodyServerHttpResponse

use of com.mendmix.gateway.filter.post.RewriteBodyServerHttpResponse in project jeesuite-libs by vakinge.

the class AbstracResponseFilter method filter.

@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
    // 
    if (exchange.getAttribute(GatewayConstants.CONTEXT_IGNORE_FILTER) != null) {
        return chain.filter(exchange);
    }
    if (RuequestHelper.isWebSocketRequest(exchange.getRequest())) {
        return chain.filter(exchange);
    }
    // 
    BizSystemModule module = RuequestHelper.getCurrentModule(exchange);
    RewriteBodyServerHttpResponse newResponse = new RewriteBodyServerHttpResponse(exchange, module);
    return chain.filter(exchange.mutate().response(newResponse).build()).then(Mono.fromRunnable(() -> {
        Long start = exchange.getAttribute(GatewayConstants.CONTEXT_REQUEST_START_TIME);
        if (logger.isDebugEnabled() && start != null) {
            logger.debug(">request_time_trace -> uri:{},useTime:{} ms", exchange.getRequest().getPath().value(), (System.currentTimeMillis() - start));
        }
    }));
}
Also used : RewriteBodyServerHttpResponse(com.mendmix.gateway.filter.post.RewriteBodyServerHttpResponse) BizSystemModule(com.mendmix.gateway.model.BizSystemModule)

Aggregations

RewriteBodyServerHttpResponse (com.mendmix.gateway.filter.post.RewriteBodyServerHttpResponse)1 BizSystemModule (com.mendmix.gateway.model.BizSystemModule)1