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);
}
Aggregations