public static RequestSpec generateTestData(String modelType, int number) { RequestSpec rs = new RequestSpec(); rs.method = H.Method.POST; rs.headers.put(CONTENT_TYPE, H.Format.JSON.contentType()); rs.url = "/~/test/generateTestData"; rs.json = JSON.toJSONString(C.Map("modelType", modelType, "number", number)); return rs; } }
public static RequestSpec generateTestData(String modelType, int number) { RequestSpec rs = new RequestSpec(); rs.method = H.Method.POST; rs.headers.put(CONTENT_TYPE, H.Format.JSON.contentType()); rs.url = "/~/test/generateTestData"; rs.json = JSON.toJSONString(C.Map("modelType", modelType, "number", number)); return rs; } }
public static RequestSpec loadFixtures(List<String> fixtures) { RequestSpec rs = new RequestSpec(); rs.method = H.Method.POST; rs.headers.put(CONTENT_TYPE, H.Format.JSON.contentType()); rs.url = "/~/test/fixtures"; rs.json = JSON.toJSONString(C.Map("fixtures", fixtures)); return rs; }
@Override public DirectRender directRenderFor(H.Format acceptType) { MimeType mimeType = MimeType.findByContentType(acceptType.contentType()); if (mimeType.test(MimeType.Trait.excel)) { return ExcelDirectRender.INSTANCE; } return null; }
protected void setContentType(H.Request req, H.Response resp) { String s = req.accept().contentType(); String encoding = resp.characterEncoding(); if(S.notBlank(encoding)) { s = S.concat(s, "; charset=", encoding); } resp.initContentType(s); }
private H.Response writeContent(String content, H.Format contentType) { contentType(contentType.contentType()); writeContent(content); return this; }
@Override public ActResponse contentType(H.Format fmt) { contentType = fmt.contentType(); return super.contentType(fmt); }
public static RequestSpec loadFixtures(List<String> fixtures) { RequestSpec rs = new RequestSpec(); rs.method = H.Method.POST; rs.headers.put(CONTENT_TYPE, H.Format.JSON.contentType()); rs.url = "/~/e2e/fixtures"; rs.json = JSON.toJSONString(C.Map("fixtures", fixtures)); return rs; } }
public static RequestSpec loadFixtures(List<String> fixtures) { RequestSpec rs = new RequestSpec(); rs.method = H.Method.POST; rs.headers.put(CONTENT_TYPE, H.Format.JSON.contentType()); rs.url = "/~/test/fixtures"; rs.json = JSON.toJSONString(C.Map("fixtures", fixtures)); return rs; }
private ActionContext applyContentType(H.Format fmt) { if (null != fmt) { ActResponse resp = response; resp.initContentType(fmt.contentType()); resp.commitContentType(); } return this; }
/** * Returns a {@link RenderBufferedImage} result wth image and format specified. * @param image * the image * @param format * the format * @return the result */ public static RenderBufferedImage renderImage(BufferedImage image, H.Format format) { return new RenderBufferedImage(image, format.contentType()); }
private ActionContext applyContentType(H.Format fmt) { if (null != fmt) { ActResponse resp = response; resp.initContentType(fmt.contentType()); resp.commitContentType(); } return this; }
private H.Response writeContent(String content, H.Format contentType) { contentType(contentType.contentType()); writeContent(content); return this; }
public Echo(String msg, String contentType) { this.buffer = ByteBuffers.wrap(msg); this.contentType = S.blank(contentType) ? H.Format.TXT.contentType() : contentType; this.toString = "echo: " + msg; }
public T contentType(H.Format fmt) { contentType(fmt.contentType()); this.fmt = fmt; return me(); }
/** * Returns a {@link RenderBufferedImage} result wth image and format specified. * @param image * the image * @param format * the format * @return the result */ public static RenderBufferedImage renderImage(BufferedImage image, H.Format format) { return new RenderBufferedImage(image, format.contentType()); }
public Echo(String msg, String contentType) { this.buffer = ByteBuffers.wrap(msg); this.contentType = S.blank(contentType) ? H.Format.TXT.contentType() : contentType; this.toString = "echo: " + msg; }
protected void setContentType(H.Request req, H.Response resp) { String s = req.accept().contentType(); String encoding = resp.characterEncoding(); if(S.notBlank(encoding)) { s = S.concat(s, "; charset=", encoding); } resp.initContentType(s); }
@Override public ActResponse contentType(H.Format fmt) { contentType = fmt.contentType(); return super.contentType(fmt); }
public T contentType(H.Format fmt) { contentType(fmt.contentType()); this.fmt = fmt; return me(); }