Search in sources :

Example 1 with StaticHandler

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());
        }
    });
}
Also used : ServiceProxyBuilder(io.vertx.serviceproxy.ServiceProxyBuilder) Router(io.vertx.ext.web.Router) StaticHandler(io.vertx.ext.web.handler.StaticHandler)

Aggregations

Router (io.vertx.ext.web.Router)1 StaticHandler (io.vertx.ext.web.handler.StaticHandler)1 ServiceProxyBuilder (io.vertx.serviceproxy.ServiceProxyBuilder)1