本文整理匯總了Java中io.vertx.ext.web.Router.mountSubRouter方法的典型用法代碼示例。如果您正苦於以下問題:Java Router.mountSubRouter方法的具體用法?Java Router.mountSubRouter怎麽用?Java Router.mountSubRouter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.ext.web.Router
的用法示例。
在下文中一共展示了Router.mountSubRouter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import io.vertx.ext.web.Router; //導入方法依賴的package包/類
@Before
public void start(TestContext context) {
super.before(context);
TestRegExRest testRest = new TestRegExRest();
Router router = RestRouter.register(vertx, testRest);
router = router.mountSubRouter("/sub", router);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(PORT);
}
示例2: start
import io.vertx.ext.web.Router; //導入方法依賴的package包/類
@Before
public void start(TestContext context) {
super.before(context);
TestPathRest testRest = new TestPathRest();
Router router = RestRouter.register(vertx, testRest);
router.mountSubRouter("/sub", router);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(PORT);
}
示例3: start
import io.vertx.ext.web.Router; //導入方法依賴的package包/類
@Before
public void start(TestContext context) {
super.before(context);
TestQueryRest testRest = new TestQueryRest();
Router router = RestRouter.register(vertx, testRest);
router.mountSubRouter("/sub", router);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(PORT);
}
示例4: start
import io.vertx.ext.web.Router; //導入方法依賴的package包/類
@Override
public void start(Future<Void> startFuture) throws Exception {
String wikiDbQueue = config().getString(CONFIG_WIKIDB_QUEUE, "wikidb.queue");
dbService = WikiDatabaseService.createProxy(vertx, wikiDbQueue);
webClient = WebClient.create(vertx, new WebClientOptions()
.setSsl(true)
.setUserAgent("vert-x3"));
HttpServer server = vertx.createHttpServer();
Router router = Router.router(vertx);
router.get("/").handler(this::indexHandler);
router.get("/backup").handler(this::backupHandler);
router.get("/wiki/:page").handler(this::pageRenderingHandler);
router.post().handler(BodyHandler.create());
router.post("/save").handler(this::pageUpdateHandler);
router.post("/create").handler(this::pageCreateHandler);
router.post("/delete").handler(this::pageDeletionHandler);
// tag::apiRouter[]
Router apiRouter = Router.router(vertx);
apiRouter.get("/pages").handler(this::apiRoot);
apiRouter.get("/pages/:id").handler(this::apiGetPage);
apiRouter.post().handler(BodyHandler.create());
apiRouter.post("/pages").handler(this::apiCreatePage);
apiRouter.put().handler(BodyHandler.create());
apiRouter.put("/pages/:id").handler(this::apiUpdatePage);
apiRouter.delete("/pages/:id").handler(this::apiDeletePage);
router.mountSubRouter("/api", apiRouter); // <1>
// end::apiRouter[]
int portNumber = config().getInteger(CONFIG_HTTP_SERVER_PORT, 8080);
server
.requestHandler(router::accept)
.listen(portNumber, ar -> {
if (ar.succeeded()) {
LOGGER.info("HTTP server running on port " + portNumber);
startFuture.complete();
} else {
LOGGER.error("Could not start a HTTP server", ar.cause());
startFuture.fail(ar.cause());
}
});
}