Add support for wildcard route handling - #8588
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8588 +/- ##
===========================================
+ Coverage 69.59% 85.76% +16.17%
===========================================
Files 349 350 +1
Lines 56327 56820 +493
===========================================
+ Hits 39201 48732 +9531
+ Misses 17126 8088 -9038 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds backend-consistent dynamic/wildcard route support across the Tornado (Bokeh server) and FastAPI server implementations, making matched route context available inside apps via session state.
Changes:
- Introduces
pn.state.route_paramsand updatespn.state.app_urlto reflect the concrete matched app path (including dynamic segments). - Normalizes FastAPI-style path templates to Tornado regex routes and propagates route context through HTTP, autoload, and websocket/session flows.
- Adds server tests for route context and updates server documentation index to include a wildcard routes guide.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
panel/tests/test_server.py |
Adds regression + behavior tests for wildcard root handling and route_params / app_url across backends. |
panel/io/state.py |
Exposes route_params on state and makes app_url prefer concrete app_path from the session token payload. |
panel/io/server.py |
Adds path-template → Tornado regex normalization and injects route context into request handling and websocket token refresh. |
panel/io/fastapi.py |
Hooks FastAPI session/websocket flows to preserve route context in the token payload used by Panel/Bokeh. |
panel/io/application.py |
Ensures base_url/rel_path derive from the concrete app_path and passes route context through process_request. |
doc/how_to/server/index.md |
Adds navigation entry for wildcard routes documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hoxbro
left a comment
There was a problem hiding this comment.
Only reviewed the code, not tested the functionality.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
This PR adds first-class dynamic route support across both server implementations and makes route context available inside apps in a backend-consistent way.
Users can now serve apps on dynamic routes and reliably read:
pn.state.route_paramsfor captured path variablespn.state.app_urlas the concrete matched app path for the current session (not new)It also improves route matching behavior for wildcard routes, ensures websocket/session flows preserve route context, and updates docs to present path-template syntax as the primary recommended style.
Supported route syntax
Path-template syntax (recommended, cross-backend):
/user/{name}/files/{filepath:path}Regex syntax (Tornado):
/user/([^/]+)/org/(?P<org>[^/]+)/user/(?P<user>[^/]+)For Tornado, path templates are normalized to Tornado-compatible patterns.
For FastAPI, path templates are passed through naturally and now preserve route metadata in session state.
Behavior improvements included
/ws,/metadata,/autoload.js).Examples
Tornado
FastAPI
AI Disclosure
Tool & Model: Cursor + Codex 5.3 / GPT 5.5
Usage: Used to investigate routing internals, implement dynamic route support across Tornado/FastAPI, add tests, and update documentation.
I have tested all AI-generated content in my PR.
I take responsibility for all AI-generated content in my PR.
Checklist