Object handleReqAndPostProcess(Channel ctx, boolean isKeepAlive, Req req) { Object result; try { result = handler.handleReq(ctx, isKeepAlive, req); } catch (Throwable e) { result = e; } return HandlerResultProcessor.INSTANCE.postProcessResult(req, result); }
@SuppressWarnings("unchecked") public Object postProcessResult(Req req, Object result) { if (result instanceof HttpStatus) { return result; } else if (result instanceof Req) { U.must(req == result, "Unknown request instance was received as result!"); return reqToStatus(req, result); } else if (result instanceof Resp) { U.must(req != null && req.response() == result, "Unknown response instance was received as result!"); return reqToStatus(req, result); } else if (result == null || result instanceof NotFound) { // not found return HttpStatus.NOT_FOUND; } else if ((result instanceof Future<?>) || (result instanceof org.rapidoid.concurrent.Future<?>)) { // async if (req != null) { req.async(); } return HttpStatus.ASYNC; } else if (result instanceof Results) { return ((Results) result).all(); // fetch while still inside tx (potentially) } else { return result; } }
public static Object resultOf(Req req, Object result) { result = HandlerResultProcessor.INSTANCE.postProcessResult(req, result); HttpUtils.resultToResponse(req, result); return req.response().result(); }
@SuppressWarnings("unchecked") public Object postProcessResult(Req req, Object result) { if (result instanceof HttpStatus) { return result; } else if (result instanceof Req) { U.must(req == result, "Unknown request instance was received as result!"); return reqToStatus(req, result); } else if (result instanceof Resp) { U.must(req != null && req.response() == result, "Unknown response instance was received as result!"); return reqToStatus(req, result); } else if (result == null || result instanceof NotFound) { // not found return HttpStatus.NOT_FOUND; } else if ((result instanceof Future<?>) || (result instanceof org.rapidoid.concurrent.Future<?>)) { // async if (req != null) { req.async(); } return HttpStatus.ASYNC; } else if (result instanceof Results) { return ((Results) result).all(); // fetch while still inside tx (potentially) } else { return result; } }
Object handleReqAndPostProcess(Channel ctx, boolean isKeepAlive, Req req) { Object result; try { result = handler.handleReq(ctx, isKeepAlive, req); } catch (Throwable e) { result = e; } return HandlerResultProcessor.INSTANCE.postProcessResult(req, result); }
public static Object resultOf(Req req, Object result) { result = HandlerResultProcessor.INSTANCE.postProcessResult(req, result); HttpUtils.resultToResponse(req, result); return req.response().result(); }