Like routers in most web frameworks, getting a feel for how they REALLY work is going to take a while and a lot of examples.
I've been trying to segment my router so it feels a bit like rails. Sort of. I'm using Thymeleaf templates and my router looks like:
// if you are getting a products page get products using a naive ORM
router.get("/products/*").handler(context -> {
Product.all(mongoService, res -> {
if (res.succeeded()) {
context.put("products", res.result());
context.next();
} else {
context.fail(res.cause());
}
});
});
// now the products template from template/products
router.route("/products/*").handler(
TemplateHandler.create(ThymeleafTemplateEngine.create().setMode("HTML5"),
"templates/products", "text/html"));
// everything else css/*.css images/* favicon.ico etc. out of webroot
router.route().handler(StaticHandler.create());