@Override public String[] splat() { return delegate.splat(); }
@Override public String[] splat() { return delegate.splat(); }
@Override public String[] splat() { return delegate.splat(); }
/** * 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 ""; } }); }
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); } }
String path = req.splat()[0]; String fullPath = "web/" + name + "/" + path;
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); }
String pageName = req.splat()[0];