-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Enhance URLResolverMiddleware to support host-based path resolution #1193
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1193 +/- ##
==========================================
+ Coverage 58.66% 58.71% +0.05%
==========================================
Files 498 499 +1
Lines 37130 37176 +46
==========================================
+ Hits 21781 21829 +48
+ Misses 15349 15347 -2 ☔ View full report in Codecov by Sentry. |
if request.path == '/': | ||
resolved_path = f'/{current_host}' | ||
else: | ||
resolved_path = f'/{current_host}{request.path}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add tests for this ? @abdullai-t Would request.path
have a /
preceding it or would current_host
have a trailing slash /
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
…ove path resolution logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary / Highlights
This pull request introduces significant changes to the
src/api/middlewares/url_resolver_middleware.py
file, focusing on improving URL resolution and handling of host-specific paths. The key changes include the addition of a host map and a new method for resolving paths.Enhancements to URL resolution:
host_patterns
from_main_.hosts
and initialized ahost_map
to map host regex patterns to host objects.resolve
with a new method_resolve_path
that constructs host-specific paths and resolves them.__call__
method to use_resolve_path
for resolving request paths and setrequest.path_info
accordingly.New method for path resolution:
_resolve_path
method to handle host-specific path resolution and return the resolved path orNone
if the path cannot be resolved.Details (Give details about what this PR accomplishes, include any screenshots etc)
Testing Steps (Provide details on how your changes can be tested)
Requirements (place an
x
in each[ ]
)Transparency (Project board)