本文整理了Java中spark.Request.bodyAsBytes
方法的一些代码示例,展示了Request.bodyAsBytes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.bodyAsBytes
方法的具体详情如下:
包路径:spark.Request
类名称:Request
方法名:bodyAsBytes
暂无
代码示例来源:origin: perwendel/spark
@Override
public byte[] bodyAsBytes() {
return delegate.bodyAsBytes();
}
代码示例来源:origin: perwendel/spark
/**
* @return the request body sent by the client
*/
public String body() {
if (body == null) {
body = StringUtils.toString(bodyAsBytes(), servletRequest.getCharacterEncoding());
}
return body;
}
代码示例来源:origin: com.sparkjava/spark-core
@Override
public byte[] bodyAsBytes() {
return delegate.bodyAsBytes();
}
代码示例来源:origin: com.conveyal/r5
/**
* Deserializes an object of the given type from the body of the supplied Spark request.
*/
public static <T> T objectFromRequestBody(spark.Request request, Class<T> classe) {
try {
return lenientObjectMapper.readValue(request.bodyAsBytes(), classe);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: conveyal/r5
/**
* Deserializes an object of the given type from the body of the supplied Spark request.
*/
public static <T> T objectFromRequestBody(spark.Request request, Class<T> classe) {
try {
return lenientObjectMapper.readValue(request.bodyAsBytes(), classe);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: com.sparkjava/spark-core
/**
* @return the request body sent by the client
*/
public String body() {
if (body == null) {
body = StringUtils.toString(bodyAsBytes(), servletRequest.getCharacterEncoding());
}
return body;
}
代码示例来源:origin: beryx/text-io
@Override
public void init() {
post("/" + getPathForPostInit(), (request, response) -> {
logger.trace("Received INIT");
String initData = new String(request.bodyAsBytes(), StandardCharsets.UTF_8);
return configureResponseData(response, handleInit(request, initData));
});
get("/" + getPathForGetData(), "application/json", (request, response) -> {
logger.trace("Received GET");
return configureResponseData(response, handleGetData(request));
});
post("/" + getPathForPostInput(), (request, response) -> {
logger.trace("Received POST");
boolean userInterrupt = Boolean.parseBoolean(request.headers("textio-user-interrupt"));
String handlerId = request.headers("textio-handler-id");
String input = new String(request.body().getBytes(), StandardCharsets.UTF_8);
return configureResponseData(response, handlePostInput(request, input, userInterrupt, handlerId));
});
}
}
内容来源于网络,如有侵权,请联系作者删除!