All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mangoo.routing.handlers.MetricsHandler Maven / Gradle / Ivy

The newest version!
package io.mangoo.routing.handlers;

import io.mangoo.routing.listeners.MetricsListener;
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;

public class MetricsHandler implements HttpHandler {
    public static final HandlerWrapper HANDLER_WRAPPER = MetricsHandler::new;
    private final HttpHandler nextHandler;

    public MetricsHandler(HttpHandler next) {
        this.nextHandler = next;
    }

    @Override
    public void handleRequest(HttpServerExchange exchange) throws Exception {
        if (!exchange.isComplete()) {
            exchange.addExchangeCompleteListener(new MetricsListener(System.currentTimeMillis()));
        }
        nextHandler.handleRequest(exchange);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy