how to organize the router

72 views
Skip to first unread message

Liangchou Zhou

unread,
Mar 28, 2019, 11:55:30 AM3/28/19
to vert.x
1 main router to bind all the handlers is not good. 

how to organize the router, e.g. offload to subrouter?

there is mountSubrouter, but i can't find how to use it. can someone how the code example?

thanks

Ronoel Júnior

unread,
Mar 28, 2019, 5:02:13 PM3/28/19
to ve...@googlegroups.com
Is it what are you looking for?

Router router = Router.router(this.vertx);
Router subRouter = Router.router(this.vertx);
router.mountSubRouter("/subroute", subRouter);

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f2955716-4181-44b8-a84c-56513bd5ca18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Ronoel Júnior

Liangchou Zhou

unread,
Mar 28, 2019, 9:16:29 PM3/28/19
to vert.x
Thanks.

i expect the main router in 1 class file, and subrouters and the related handlers reside in other class file.

Should the code organize in the following way?

MainVerticle

Router router = Router.router(this.vertx);
Router subRouter = Router.router(this.vertx);
router.mountSubRouter("/subroute", SubVerticle.getRouter());


SubVerticle

Router getRouter() {

Router subRouter = Router.router(this.vertx);
router.mountSubRouter("/subroute", subRouter);
}

在 2019年3月29日星期五 UTC+8上午5:02:13,Ronoel Junior写道:
Is it what are you looking for?

Router router = Router.router(this.vertx);
Router subRouter = Router.router(this.vertx);
router.mountSubRouter("/subroute", subRouter);

On Thu, Mar 28, 2019 at 12:55 PM Liangchou Zhou <liangc...@gmail.com> wrote:
1 main router to bind all the handlers is not good. 

how to organize the router, e.g. offload to subrouter?

there is mountSubrouter, but i can't find how to use it. can someone how the code example?

thanks

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ve...@googlegroups.com.


--
Ronoel Júnior
Reply all
Reply to author
Forward
0 new messages