Skip to content

Access registered Route objects #3082

Answered by jknack
axelbdt asked this question in Q&A
Discussion options

You must be logged in to vote

Multiple ways. Each execution is tied to a route:

webRoute(Context ctx) {
   var route = ctx.getRoute();
}

You can list all them too:

webRoute(Context ctx) {
   var router = ctx.getRouter();
   var routes = router.getRoutes();
}

A route is available as soon as you add it to the router:

{
      var myRoute = get("/route-api", ctx -> {...})

      // get all the routes registered so far
      var routes = getRoutes();

     // get all the routes
     onStarted(() -> {
           var all = getRoutes();
     });
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@axelbdt
Comment options

Answer selected by axelbdt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants