Search in sources :

Example 1 with ReporterHandler

use of io.gravitee.gateway.reactor.handler.reporter.ReporterHandler in project gravitee-gateway by gravitee-io.

the class DefaultReactor method route.

@Override
public void route(Request serverRequest, Response serverResponse, final Handler<Response> handler) {
    LOGGER.debug("Receiving a request {} for path {}", serverRequest.id(), serverRequest.path());
    // Prepare handler chain
    Handler<Request> requestHandlerChain = transactionHandlerFactory.create(request -> {
        ReactorHandler reactorHandler = reactorHandlerResolver.resolve(request);
        if (reactorHandler != null) {
            // Prepare the handler chain
            Handler<Response> responseHandlerChain = new ResponseTimeHandler(request, new ReporterHandler(reporterService, request, handler));
            reactorHandler.handle(request, serverResponse, responseHandlerChain);
        } else {
            LOGGER.debug("No handler can be found for request {}, returning NOT_FOUND (404)", request.path());
            sendNotFound(serverResponse, handler);
        }
    }, serverResponse);
    // Set gateway tenant
    serverRequest.metrics().setTenant(gatewayConfiguration.tenant().orElse(null));
    // And handle the request
    requestHandlerChain.handle(serverRequest);
}
Also used : Response(io.gravitee.gateway.api.Response) ReactorHandler(io.gravitee.gateway.reactor.handler.ReactorHandler) ReporterHandler(io.gravitee.gateway.reactor.handler.reporter.ReporterHandler) ResponseTimeHandler(io.gravitee.gateway.reactor.handler.ResponseTimeHandler) Request(io.gravitee.gateway.api.Request)

Aggregations

Request (io.gravitee.gateway.api.Request)1 Response (io.gravitee.gateway.api.Response)1 ReactorHandler (io.gravitee.gateway.reactor.handler.ReactorHandler)1 ResponseTimeHandler (io.gravitee.gateway.reactor.handler.ResponseTimeHandler)1 ReporterHandler (io.gravitee.gateway.reactor.handler.reporter.ReporterHandler)1