router.route("/static/*").handler(StaticHandler.create())
This line of code will route all requests containing the word 'static' to the webroot folder.
More info about how Vert.x serves static content:
http://vertx.io/docs/vertx-web/kotlin/#_serving_static_resources
The default folder for static content is 'webroot', but trying to find out where to place this folder got me really confused...
From this question on Stack Overflow
https://stackoverflow.com/questions/31778971/vertx-web-where-do-i-place-webroot-folder
I can tell I'm not the first person wondering (lot's of suggestions with no approved answer)...
What I've found during testing is the following:
- Static content outside the jar
Is being served relative to the working directory, or the directory you're in when starting the app from the command line.
If you have a folder called 'webroot' in this directory it's content will be available through the StaticHandler object. - Static content inside the jar
If you wish to serve static content directly from your jar file you need to add 'webroot' as a resource in the jar and place all the content of interest there. In the picture below I have my resources folder at the same level as the source code. Note that the folder is marked in Intellij as a resource folder.