use of core.framework.impl.web.request.RequestImpl in project core-ng-project by neowu.
the class HTTPServerHandler method handle.
private void handle(String path, HttpServerExchange exchange) {
ActionLog actionLog = logManager.begin("=== http transaction begin ===");
RequestImpl request = new RequestImpl(exchange, requestBeanMapper);
try {
// initialize webContext at beginning, the customerErrorHandler in errorHandler may use it if any exception
webContext.initialize(request);
requestParser.parse(request, exchange, actionLog);
request.session = sessionManager.load(request);
HeaderMap headers = exchange.getRequestHeaders();
String client = headers.getFirst(HTTPServerHandler.HEADER_CLIENT);
if (client != null)
actionLog.context("client", client);
actionLog.refId(headers.getFirst(HTTPServerHandler.HEADER_REF_ID));
ControllerHolder controller = route.get(path, request.method(), request.pathParams, actionLog);
actionLog.action(controller.action);
actionLog.context("controller", controller.controllerInfo);
logger.debug("controllerClass={}", controller.controller.getClass().getCanonicalName());
// trigger trace after action is determined due to trace log use action as part of path, is there better way?
if ("true".equals(headers.getFirst(HEADER_TRACE))) {
actionLog.trace = true;
}
Response response = new InvocationImpl(controller, interceptors, request, webContext).proceed();
sessionManager.save(request, response);
responseHandler.render((ResponseImpl) response, exchange, actionLog);
} catch (Throwable e) {
logManager.logError(e);
errorHandler.handleError(e, exchange, request, actionLog);
} finally {
webContext.cleanup();
logManager.end("=== http transaction end ===");
}
}
Aggregations