Falcon: Improve falcon-print-routes tool

Created on 9 Feb 2019  路  11Comments  路  Source: falconry/falcon

falcon-print-routes is a simple (albeit somewhat spartan) tool that may come handy to list API routes.
We could polish it, and expose more widely:

  • Advertise it in the documentation (currently it is only mentioned in the 1.1.0 changelog)
  • Make it aware of route suffixes, a new feature in 2.0
  • Expose interface to be able to list routes programmatically (suggested by @CaselIT )
  • Make it clear that the tool only works with the standard CompiledRouter (suggested by @CaselIT )
  • Anything else? (suggestions welcome!)
enhancement good first issue needs contributor

All 11 comments

I'll pick this one up!

Cool, I didn't expect anyone to pick this so soon 馃憤
Just a note: you may want to wait for this to land, or start off my branch -- it fixes a couple of bugs in this tool: https://github.com/falconry/falcon/pull/1399

Sure I can wait, I know we are deep in 2.0 beta territory as well. I have fond memories of when flask routes came out, so this is a nice thing for me to work on while I'm still learning a lot about how falcon works under the hood. 馃槃

Well, as said, you don't really need to wait -- you can always just fork off my branch :slightly_smiling_face:

Edit: FWIW, the changes hit master now.

Hi again @Nateyo !
Just wanted to check if you were still working on this tool, or had any code to share that someone else could pick up?

@vytas7 I think another point to add is a check that the router is the default compiled router, since it will only work with that.

Also maybe moving the actual code that lists the routes in another module, like in falcon.utils.explore_routes or falcon.routing.explore_routes and make the script import it, would be easier to reuse programmatically.

Thanks for these suggestions @CaselIT!
I updated the issue description.

Other random thought:

Add a debug keyword to the App (or to App.add_route) so that a log is printed every time a route is added to the application. This could be useful when first debugging the application to have an immediate feedback what routes are there and what causes a problem.

Regarding a kw in App vs one in App.add_route maybe one in App could be nicer since there could be similar logs for every "setup" call to the application. By setup I mean constructor log (middleware), calls to add_route, add_static_route, etc, basically everything that does not involve the normal handling of a request.

Maybe I can open another issue regarding this?

That would be more fitting a separate issue IMHO, yeah. :arrow_upper_left:

I'm working on this in #1661

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hadiasheri picture hadiasheri  路  3Comments

w1z2g3 picture w1z2g3  路  7Comments

bachrc picture bachrc  路  3Comments

carlodri picture carlodri  路  5Comments

neilalbrock picture neilalbrock  路  5Comments