Reputation: 21030
I need to get list of all the registered routes in Hono, similar to the one that Hapi's table()
API or Fastify plugin fastify-print-routes
.
Is there any internal API I can use to get this information? I cannot find anything from the official documentation!
Upvotes: 1
Views: 1200
Reputation: 21
You can use app.routes
.
The output will be:
[
{
path: <PATH>,
method: <METHOD>,
handler: [AsyncFunction (anonymous)]
},
...
]
Upvotes: 1
Reputation: 619
The hono/dev
package has a showRoutes
function that will log the routes to console. Hono documentation
It also has an inspectRoutes
that's not in the documentation, but is used to generate the info in showRoutes
. It returns the information you're looking for (path, method). Source code
Upvotes: 3