Skip to content

Miscellaneous

getRoutes()

getRoutes() — returns any

Available in: mapper

Returns all the routes that have been defined in the application via the mapper() function. It provides a programmatic way to inspect the routing table, including route names, URL patterns, controllers, actions, and other metadata. This is useful for debugging, generating dynamic links, or performing logic based on the routes that exist in your application.

1. Get all defined routes
allRoutes = application.wheels.mapper.getRoutes();

// Loop through routes and display their patterns
for (var r in allRoutes) {
    writeOutput("Route name: " & r.name & "<br>");
    writeOutput("Pattern: " & r.pattern & "<br>");
    writeOutput("Controller: " & r.controller & "<br>");
    writeOutput("Action: " & r.action & "<br><br>");
}