In Rails I view all the routes I have defined via:
rake routes
Is there a built in way to do this in a Roda app?
If not, is there a common pattern Roda developers use to quickly view all the routes (maybe a Rake task of some sorts?)
In Rails I view all the routes I have defined via:
rake routes
Is there a built in way to do this in a Roda app?
If not, is there a common pattern Roda developers use to quickly view all the routes (maybe a Rake task of some sorts?)
Automatically is not possible.
rodaroutes are evaluated dynamically when a request comes in, so they are not loaded before and stored in a data structure available somewhere.As the documentation says:
A simple solution, which needs a minimal effort, is to use the
roda-route_listplugin, but it needs explanatory comment on the top of each route in yourapp.rbfile, like this:(check the documentation for other possibilities)
Then you have to create a json file containing the routes metadata, you can do this launching a script shipped with
roda-route_listpluginIt creates the file
routes.jsonin the root of your app and finally you can list the routes with:You could create also a simple rake task to list all routes, something like this:
maybe there is a more elegant solution than this snippet, but it works :)
Hope it helps!