Vert.x RESTful Verticle
<p>I am extremely new to Vert.x, like a couple of days new. I come from a JAX-RS, RESTeasy world. I might be extremely wrong, please correct me.</p>

<p>So, I want to write a REST API using vertx-web and Spring. I see Verticles as REST resources.
I took a look on <a href="http://vertx.io/blog/some-rest-with-vert-x/" rel="nofollow">vertx-web blog</a> and <a href="https://github.com/vert-x3/vertx-examples/tree/master/spring-examples/spring-example" rel="nofollow">spring-example</a>, but the examples are pretty simple, and mostly comprised of only one resource and verticle.</p>

<p><strong>My question is</strong>: How do you make a Verticle expose its own REST interface (sub-router), and how do you register its sub-router into application's main-router?</p>

<p>I have tried something like but i get 404 when I request /products/all :(</p>

<pre><code>public class ProductsVerticle extends AbstractVerticle {

@Override
public void start(Future&lt;Void&gt; startFuture) throws Exception {
    super.start(startFuture);
}

public static Router getRouter() {
    Router router = Router.router(Vertx.vertx());

    router.get("/all").consumes("application/json").produces("application/json")
            .handler(routingContext -&gt; {
                routingContext.response()
                        .putHeader("content-type", "text/html")
                        .end("&lt;h1&gt;Products&lt;/h1&gt;");
            });

    return router;
}
</code></pre>

<p>}</p>

<pre><code>public class ServerVerticle extends AbstractVerticle {

@Override
public void start() throws Exception {
    super.start();

    Router mainRouter = Router.router(vertx);
    ProductsVerticle productsVerticle = new ProductsVerticle();

    vertx.deployVerticle(productsVerticle, handler -&gt; {
        if (handler.succeeded()) {
            LOG.info("Products Verticle deployed successfully");
            mainRouter.mountSubRouter("/products", productsVerticle.getRouter());
        }
    });

    mainRouter.get("/static").handler(routingContext -&gt; {
        routingContext.response()
                .putHeader("content-type", "text/html")
                .end("&lt;h1&gt;Hello from my first Vert.x 3 application&lt;/h1&gt;");
    });

    HttpServer server = vertx.createHttpServer();
    server.requestHandler(mainRouter::accept);
    server.listen(8090);
}
</code></pre>

<p>}</p>