private static boolean shouldRenderView(Resp resp) { if (!resp.mvc()) return false; Object result = resp.result(); if (result == null) return true; if (((RespImpl) resp).hasCustomView()) return U.notEmpty(resp.view()); return true; }
private String validateResponse() { if (response == null) { return "Response wasn't provided!"; } if (response.result() == null && response.body() == null && response.redirect() == null && response.file() == null && response.raw() == null && !response().mvc()) { return "Response content wasn't provided!"; } if (response.contentType() == null && response.raw() == null) { return "Response content type wasn't provided!"; } return null; }
protected Object page(Req req, Resp resp, Throwable error) { if (error instanceof SecurityException) { resp.model("embedded", req.attr("_embedded", false)); resp.model("req", req); resp.model("loginUri", Msc.specialUri("login")); return resp.code(403).view("login").mvc(true); } else { BasicConfig zone = HttpUtils.zone(req); String home = zone.entry("home").or("/"); Map<String, ?> errorInfo = HttpUtils.getErrorInfo(resp, error); resp.model("req", req); resp.model("error", errorInfo); resp.model("home", home); return resp.mvc(true).view("error"); } }
private void execHandlerJob(final Channel channel, final boolean isKeepAlive, final MediaType contentType, final Req req) { With.tag(CTX_TAG_HANDLER).exchange(req).run(() -> { try { req.response() .view(options.view()) .contentType(options.contentType()) .mvc(options.mvc()); handleWithWrappers(channel, isKeepAlive, contentType, req, wrappers.get()); } catch (Throwable e) { handleError(req, e); } }); }
private static boolean shouldRenderView(Resp resp) { if (!resp.mvc()) return false; Object result = resp.result(); if (result == null) return true; if (((RespImpl) resp).hasCustomView()) return U.notEmpty(resp.view()); return true; }
@Override public void run() { try { req.response() .view(options.view()) .contentType(options.contentType()) .mvc(options.mvc()); handleWithWrappers(channel, isKeepAlive, contentType, req, wrappers.get()); } catch (Throwable e) { handleError(req, e); } }
private String validateResponse() { if (response == null) { return "Response wasn't provided!"; } if (response.result() == null && response.body() == null && response.redirect() == null && response.file() == null && response.raw() == null && !response().mvc()) { return "Response content wasn't provided!"; } if (response.contentType() == null && response.raw() == null) { return "Response content type wasn't provided!"; } return null; }
protected Object page(Req req, Resp resp, Throwable error) { if (error instanceof SecurityException) { resp.model("embedded", req.attr("_embedded", false)); resp.model("req", req); resp.model("loginUri", Msc.specialUri("login")); return resp.code(403).view("login").mvc(true); } else { BasicConfig zone = HttpUtils.zone(req); String home = zone.entry("home").or("/"); Map<String, ?> errorInfo = HttpUtils.getErrorInfo(resp, error); resp.model("req", req); resp.model("error", errorInfo); resp.model("home", home); return resp.mvc(true).view("error"); } }