Dynamically add routes to Router after deployment

297 views
Skip to first unread message

Stuart

unread,
Aug 14, 2018, 1:29:21 PM8/14/18
to vert.x
Hi all,

Thanks for the help answers my recent questions! It is great to have such a responsive forum.

I am planning to deploy a http server verticle and then after it is deployed use the Router object so I can dynamically add new routes. Is this ok to do?

e.g. On my verticle I was going to expose a method routePost(String path, Handler<RoutingContext> handler) which would call the relevant method on the Router.

Cheers,

Stuart

Blake

unread,
Aug 19, 2018, 11:58:41 AM8/19/18
to vert.x
From a vertx standpoint this is okay. It's just going to add them at the end of the route chain. You might run into some cases where you're registering the same route multiple times or you're never going to reach a route because another route handles it beforehand, so be careful with the implementation. You could maybe alleviate some of this by using route().order(), but my guess is that this is going to be pretty messy (with or without setting order) if you've got a lot of dynamic paths being added.

Stuart

unread,
Aug 19, 2018, 7:40:34 PM8/19/18
to vert.x
Understood, thanks.
Reply all
Reply to author
Forward
0 new messages