pallets-eco / flask-debugtoolbar

A toolbar overlay for debugging Flask applications
https://flask-debugtoolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
952 stars 146 forks source link

Add support for Flask.host_matching #274

Closed samuelhwilliams closed 4 months ago

samuelhwilliams commented 4 months ago

Allows configuration of Flask-DebugToolbar to support a Flask app running in host_matching mode.

When Flask is configured this way, routes are each tied to a host definition. This can either be a single explicit host, or a host definition that includes variable values similar to Werkzeug path definitions, eg <subdomain>.toolbar.com.

Handling explicit domains is simple, as the host can be passed through directly - and this happens automatically.

If the host contains any variable parts, then calls to url_for need to be able to access the appropriate values for those variables. If the host string specified by the user contains arbitrary variables, it's difficult for the toolbar to know what those should evaluate to. So we restrict the possible options for the toolbar host to one of two options here: either a single explicit host, or a full-wildcard host. The wildcard host is managed internally by Flask-DebugToolbar so that we know: 1) the variable name, and 2) what value to inject for it (the current request's host).

Fix: https://github.com/pallets-eco/flask-debugtoolbar/issues/269

samuelhwilliams commented 4 months ago

Are we good to merge this in? What needs to happen to schedule a release with this change? :)

Please let me know if you're waiting on anything from my end.