@Override public void renderTo(Writable output, Object model) { doRender(Msc.locals(), output, model); }
@Override public byte[] renderToBytes(Object model) { RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.templateRenderingOutput(); doRender(locals, out, model); return out.copy(); }
public void renderMultiModel(OutputStream output, Object... model) { doRenderMulti(Msc.locals(), new WritableOutputStream(output), U.list(model)); }
public static byte[] renderPage(ReqImpl req, String content) { PageDecorator pageDecorator = Customization.of(req).pageDecorator(); U.must(pageDecorator != null, "A page decorator wasn't configured!"); ReusableWritable out = Msc.locals().pageRenderingStream(); try { pageDecorator.renderPage(req, content, out); } catch (Exception e) { throw U.rte("Error while rendering page!", e); } return out.copy(); }
protected void writeJsonBody(MaybeReq req, Channel ctx, Object value) { writeContentTypeHeader(ctx, MediaType.JSON); ReusableWritable out = Msc.locals().jsonRenderingStream(); JSON.stringify(value, out); HttpIO.INSTANCE.writeContentLengthHeader(ctx, out.size()); HttpIO.INSTANCE.closeHeaders(req, ctx.output()); ctx.write(out.array(), 0, out.size()); }
private void writeJsonResponse(MaybeReq req, Resp resp, Channel ctx, boolean isKeepAlive, int code, MediaType contentType, Object result) { startResponse(resp, ctx, code, isKeepAlive, contentType); RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.jsonRenderingStream(); // FIXME headers JSON.stringify(result, out); writeContentLengthHeader(ctx, out.size()); closeHeaders(req, ctx.output()); ctx.write(out.array(), 0, out.size()); }
@Override public void renderTo(Writable output, Object model) { doRender(Msc.locals(), output, model); }
@Override public byte[] renderToBytes(Object model) { RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.templateRenderingOutput(); doRender(locals, out, model); return out.copy(); }
public void renderMultiModel(OutputStream output, Object... model) { doRenderMulti(Msc.locals(), new WritableOutputStream(output), U.list(model)); }
public static byte[] renderPage(ReqImpl req, String content) { PageDecorator pageDecorator = Customization.of(req).pageDecorator(); U.must(pageDecorator != null, "A page decorator wasn't configured!"); ReusableWritable out = Msc.locals().pageRenderingStream(); try { pageDecorator.renderPage(req, content, out); } catch (Exception e) { throw U.rte("Error while rendering page!", e); } return out.copy(); }
protected void writeJsonBody(MaybeReq req, Channel ctx, Object value) { writeContentTypeHeader(ctx, MediaType.JSON); ReusableWritable out = Msc.locals().jsonRenderingStream(); JSON.stringify(value, out); HttpIO.INSTANCE.writeContentLengthHeader(ctx, out.size()); HttpIO.INSTANCE.closeHeaders(req, ctx.output()); ctx.write(out.array(), 0, out.size()); }
private void writeJsonResponse(MaybeReq req, Resp resp, Channel ctx, boolean isKeepAlive, int code, MediaType contentType, Object result) { startResponse(resp, ctx, code, isKeepAlive, contentType); RapidoidThreadLocals locals = Msc.locals(); ReusableWritable out = locals.jsonRenderingStream(); // FIXME headers JSON.stringify(result, out); writeContentLengthHeader(ctx, out.size()); closeHeaders(req, ctx.output()); ctx.write(out.array(), 0, out.size()); }