spark.Request.splat()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中spark.Request.splat方法的一些代码示例,展示了Request.splat的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.splat方法的具体详情如下:
包路径:spark.Request
类名称:Request
方法名:splat

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];

相关文章