本文整理了Java中spark.Request.splat
方法的一些代码示例,展示了Request.splat
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.splat
方法的具体详情如下:
包路径:spark.Request
类名称:Request
方法名:splat
[英]Returns an arrat containing the splat (wildcard) parameters
[中]返回包含splat(通配符)参数的arrat
代码示例来源:origin: perwendel/spark
@Override
public String[] splat() {
return delegate.splat();
}
代码示例来源:origin: cinchapi/concourse
@Override
public String[] splat() {
return delegate.splat();
}
代码示例来源:origin: com.sparkjava/spark-core
@Override
public String[] splat() {
return delegate.splat();
}
代码示例来源:origin: lamarios/Homedash2
/**
* Endpoints to access resoruces from cache
*/
private static void cacheResources() {
// serving file from cache
get("/cache/*", (request, response) -> {
File file = new File(Constants.CACHE_FOLDER + request.splat()[0]);
logger.info("Looking for file [{}]", file.getAbsolutePath());
if (file.exists()) {
response.raw().setContentType("application/octet-stream");
response.raw().setHeader("Content-Disposition", "attachment; filename=" + file.getName());
FileInputStream in = new FileInputStream(file);
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) > 0) {
response.raw().getOutputStream().write(buffer, 0, len);
}
in.close();
return response.raw();
} else {
response.status(404);
return "";
}
});
}
代码示例来源:origin: mgtechsoftware/smockin
String extractInboundValue(final RuleMatchingTypeEnum matchingType, final String fieldName, final Request req) {
switch (matchingType) {
case REQUEST_HEADER:
return req.headers(fieldName);
case REQUEST_PARAM:
return extractRequestParam(req, fieldName);
case REQUEST_BODY:
return req.body();
case PATH_VARIABLE:
return req.params(fieldName);
case PATH_VARIABLE_WILD:
final int argPosition = NumberUtils.toInt(fieldName, -1);
if (argPosition == -1
|| req.splat().length < argPosition) {
throw new IllegalArgumentException("Unable to perform wildcard matching on the mocked endpoint '" + req.pathInfo() + "'. Path variable arg count does not align.");
}
return req.splat()[(argPosition - 1)];
case REQUEST_BODY_JSON_ANY:
final Map<String, ?> json = GeneralUtils.deserialiseJSONToMap(req.body());
return (json != null)?(String)json.get(fieldName):null;
default:
throw new IllegalArgumentException("Unsupported Rule Matching Type : " + matchingType);
}
}
代码示例来源:origin: lamarios/Homedash2
String path = req.splat()[0];
String fullPath = "web/" + name + "/" + path;
代码示例来源:origin: lamarios/Homedash2
private static void staticResources() {
Route route = (Route) (req, res) -> {
if (Constants.DEV_MODE) {
String content = getDevStaticResource(req.splat()[0], res);
if (content != null) {
return content;
}
//if it's not in the assets we just load it as a normal file
}
String fullPath = "web" + req.pathInfo();
return getContent(res, fullPath);
};
get("/css/*", route);
get("/fonts/*", route);
get("/js/*", route);
get("/images/*", route);
}
代码示例来源:origin: dessalines/torrenttunes-client
String pageName = req.splat()[0];
内容来源于网络,如有侵权,请联系作者删除!