Routes added to add_sink override static routes added with add_static_route
See original GitHub issueHi Falcon team,
Thanks for all your hard work. I ran into an issue today when I tried to make use of the add_static_route
method.
Our project uses add_sink
to implement a custom handler for requests with no corresponding handler. However, that add_sink
function would gobble up any requests that we intended to be handled by the static route:
api.add_static_route('/static', valid_static_file_path) # Would never get called
api.add_sink(unmatched_route_handler) # Would always swallow calls to assets at `/static/WHATEVER`
The case was the same whether the static route was added before or after the sink.
I would expect that if a static route is added, that resource path is excluded for any sink handlers.
My workaround for now was to basically use a regex on the sink to exclude the static path:
api.add_sink(unmatched_route_auth_wrapper, '^((?!static).)*$')
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Do track routes override static routes? - Cisco Community
Solved: I ran into a weird issue today I'm trying to figure out. I recently added some SLA monitors and tracks for routes...
Read more >How to Add or Remove Static Route on Windows - Action1
We will use the so-called 'Root' — meaning we will prescribe routes using the 'route add' command in the Windows command line. Let's...
Read more >Chapter 20. Configuring static routes Red Hat Enterprise Linux 8
routes sub-command, nmcli overrides all current settings of this parameter. To add a route:.
Read more >How to Permanently add Static Route in Linux - LinuxOPsys
Here learn how to add permanent static routes in Linux distributions such as CentOS Stream and Ubuntu. Here routes needs be added to...
Read more >How to add a static route using a PowerShell cmdlet
We show you how to add static routes and its associated parameters to a routing table in Windows using PowerShell cmdlets.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve added a pr #1769 to invert the precedence of the sinks and static routes via a configuration parameter of the app.
By default the behavior is the same as the current one, so no breaking change was added
I think how the
App
interacts with the sinks and static files could be unified to have a single for loop, the two arrays can be simply chained one way or the other according to the setting (this could also be done statically, each time a sink/static file route is added).https://github.com/falconry/falcon/blob/d946b4f0acf6c9fd25015f517499880c19533932/falcon/app.py#L845-L859