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
feat(routing): add support for multiple path segment fields #1945
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1945 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 63 63
Lines 6715 6752 +37
Branches 1243 1254 +11
=========================================
+ Hits 6715 6752 +37
Continue to review full report at Codecov.
|
|
@CaselIT Have you considered to buck the trend seen among other frameworks where this is packaged as a converter, and add new syntax to router templates instead? I don't know what the most aesthetic way to express that could be, but the advantage would be that one could use any converter with a path segment, or even use no converter for simple cases? (This is just a random idea though, maybe it makes sense to have a |
I'm not really sold on the idea, since it's another thing that should be documented, explained etc. I think your example would work better with |
Agreed that my idea ain't very pretty either. |
Since the interface of the converters changes, I think it makes sense to have two implementation in that case. (path like converters get passed a list of path segments, not a single segment) |
Another issue that is useful to have in mind when discussing the big picture: #1567 (which would actually favour your current design, but maybe we could devise a more generic way to provide hints?) |
From a quick look I don't think that the current implementation is incompatible with that issue |
I know that although Falcon has moved away from RFC 6570, the said paper has all kinds of funky expansions, so maybe something familiar could be adapted from Section 3.2.6, like Maybe we could have a discussion [meeting?] about this on chat at some point 🤔 I don't have any elegant suggestions, but maybe someone else does. |
That may be an option, but we risk having two ways of doing something, having both the converters and this special syntax. |
Dunno, I was just thinking what the options were before we move forward with this. But we should move forward in one or another way 🙂 |
It would be also good to reason about this change in the perspective of adding Of course, there are different ways to accommodate this in the |
Yes so, I think no converter should match 0 fields, because that would be a substantial change in comparison to how the framework behaves now. Matching an empty string after a trailing slash is a bit special edge case (or oversight) which already exists now, so path converter can also do the same, but |
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.
This is shaping up, well done 👍
A couple of inline nitpicks aside, we also ought to revise this FAQ item: How can I handle forward slashes within a route template field?
thanks for the review
it does not at the moment. |
lol, this is why it is good to require >= 2 approvals. You guys inevitably catch things I miss. |
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 sans the still pending FAQ update: How can I handle forward slashes within a route template field?
sorry I missed the previous message. Will do that |
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 of Changes
This adds support for a converter to be declared as consuming all the remaining path.
The current implementation does not allow nesting these converters and is quite conservative (I think), but I believe we can improve on this later if we need to.
Related Issues
Closes #423
Fixes #648
Relates to #1895
Pull Request Checklist
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once; it will save you a few review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.
docs/
.docs/
.versionadded
,versionchanged
, ordeprecated
directives.docs/_newsfragments/
, with the file name format{issue_number}.{fragment_type}.rst
. (Runtowncrier --draft
to ensure it renders correctly.)If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!
PR template inspired by the attrs project.