use of io.vertx.ext.web.handler.StaticHandler in project vertx-examples by vert-x3.
the class BookRestApi method start.
@Override
public void start(Future<Void> startFuture) throws Exception {
bookAsyncService = new ServiceProxyBuilder(vertx).setAddress(BookAsyncService.ADDRESS).build(BookAsyncService.class);
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.post("/book").handler(this::addBook);
router.get("/books").handler(this::getAllBooks);
StaticHandler staticHandler = StaticHandler.create();
router.route().handler(staticHandler);
vertx.createHttpServer().requestHandler(router::accept).listen(8080, listen -> {
if (listen.succeeded()) {
LOG.info("BookRestApi started");
startFuture.complete();
} else {
startFuture.fail(listen.cause());
}
});
}
Aggregations