@Test public void testServerFileSystemPath() throws Exception { router.clear(); File file = File.createTempFile("vertx", "tmp"); file.deleteOnExit(); // remap stat to the temp dir try { stat = StaticHandler.create(file.getParent()); fail(); } catch (IllegalArgumentException e) { // expected } stat = StaticHandler.create().setAllowRootFileSystemAccess(true).setWebRoot(file.getParent()); router.route().handler(stat); testRequest(HttpMethod.GET, "/" + file.getName(), 200, "OK", ""); }
/** * Enable/Disable access to the root of the filesystem * @param allowRootFileSystemAccess whether root access is allowed * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setAllowRootFileSystemAccess(boolean allowRootFileSystemAccess) { delegate.setAllowRootFileSystemAccess(allowRootFileSystemAccess); return this; }
/** * Enable/Disable access to the root of the filesystem * @param allowRootFileSystemAccess whether root access is allowed * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setAllowRootFileSystemAccess(boolean allowRootFileSystemAccess) { delegate.setAllowRootFileSystemAccess(allowRootFileSystemAccess); return this; }
@Test public void testServerFileSystemPath() throws Exception { router.clear(); File file = File.createTempFile("vertx", "tmp"); file.deleteOnExit(); // remap stat to the temp dir try { stat = StaticHandler.create(file.getParent()); fail(); } catch (IllegalArgumentException e) { // expected } stat = StaticHandler.create().setAllowRootFileSystemAccess(true).setWebRoot(file.getParent()); router.route().handler(stat); testRequest(HttpMethod.GET, "/" + file.getName(), 200, "OK", ""); }
private void initStaticResourceHandler() { StaticHandler staticHandler = StaticHandler.create(); if (nonNull(System.getProperty("domino.webroot.location"))) { staticHandler.setAllowRootFileSystemAccess(true); staticHandler.setWebRoot(systemWebRoot()); } else { staticHandler.setWebRoot(webroot); } router.route("/").order(Integer.MAX_VALUE - 2) .handler(this::serveIndexPage); router.route("/static/*").order(Integer.MAX_VALUE - 1) .handler(staticHandler) .failureHandler(this::serveResource); router.route("/*").order(Integer.MAX_VALUE) .handler(this::serveResource); }