HttpServer server = vertx.createHttpServer();
Router router = ...;
router.route("/static/*").handler(StaticHandler.create().setCachingEnabled(false));
server.requestHandler(router::accept).listen(ctx.port); myproject/webroot
myproject/src/main/resources/webroot
myproject/src/main/java/webroot
JAVA_OPTS="-Dmyproject.port=8099" CLASSPATH="src/main/java:src/main/resources:target/dependencies/*:target/classes" vertx run com.my.MyProject http://localhost:8099
http://localhost:8099/
http://localhost:8099/index.html
http://localhost:8099/static/css/base.cssAny requests to paths handled by the static handler will result in files being served from a directory on the file system or from the classpath. The default static file directory is webroot but this can be configured.
In the following example all requests to paths starting with /static/ will get served from the directory webroot:
var StaticHandler = require("vertx-web-js/static_handler");
router.route("/static/*").handler(StaticHandler.create().handle);/ will cause the index page to be served. By default the index page is index.html. This can be configured with setIndexPage.router.route("/static/*").handler(StaticHandler.create("webroot").setCachingEnabled(false));
router.route("/").handler(ctx -> {
Logger.log("Got an HTTP request to /");
ctx.response().sendFile("webroot/index.html").end();
});
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/63fd197d-5bcc-46e8-bbc1-c181d67d47ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.