an attempt to set up templates (https://vertx.io/docs/vertx-web/java/#_templates) was made

This commit is contained in:
2023-03-11 05:13:04 -06:00
parent 399d22b28f
commit b9978932d3

View File

@ -8,7 +8,14 @@ import io.vertx.ext.web.Router;
public class MainVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
// Create a Router
//Template Engine / HTML Assembler
//
//TODO: actually make this work, for some reason io.vertx.ext.web.handler.TemplateEngine doesn't exist even though it does: https://vertx.io/docs/apidocs/io/vertx/ext/web/handler/package-summary.html
io.vertx.ext.web.handler.TemplateEngine engine = io.vertx.reactivex.ext.web.templ.freemarker.FreeMarkerTemplateEngine.create();
io.vertx.ext.web.handler.TemplateHandler templateHandler = io.vertx.ext.web.handler.TemplateHandler.create(engine);
// Create a Routeir
Router router = Router.router(vertx);
// Mount the handler for all incoming requests at every path and HTTP method
@ -25,11 +32,15 @@ public class MainVerticle extends AbstractVerticle {
db.executeQuery("SELECT * FROM testtable", rc, Database.OUTPUT_DATATYPE_JSON);
}
);
router.get("/htmlTest").handler(rc -> {
db.executeQuery("SELECT * FROM testtable", rc, Database.OUTPUT_DATATYPE_HTML);
}
);
router.get("/dynamic/*").handler(templateHandler);