-
Notifications
You must be signed in to change notification settings - Fork 0
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
RFC: Route Overlapping #9
Conversation
Summary of changes and their impacts
|
3832f51
to
7b86e97
Compare
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
==========================================
- Coverage 87.65% 84.47% -3.19%
==========================================
Files 8 12 +4
Lines 1231 1552 +321
==========================================
+ Hits 1079 1311 +232
- Misses 125 216 +91
+ Partials 27 25 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
7b1cb7a
to
2cfe7fc
Compare
0e54261
to
fa16505
Compare
4842be5
to
5c83d40
Compare
Introduction
Fox uses a Radix tree for route matching, ensuring fast and efficient routing. Currently, this router only supports explicit matches and does not allow overlapping routes. However, there are valid use cases where allowing a certain level of route overlap would be beneficial without significantly impacting performance.
This RFC proposes a change that allows limited route overlapping while maintaining high performance and enhancing flexibility. The aim is to find a balance between the performance of the router and the flexibility of route definition.
Background
Currently, routes such as:
and
are not supported, as they overlap.
Proposal
Allow limited route overlapping by prioritizing more specific routes and permitting only one named or catch-all route to overlap with a static route segment.
Rules
Not Allowed
/*{filepath}
and/{user}/track
)./users/{id}
and/users/{name}
).Example
Thoses routes should be allowed with the proposed enhancements.
These routes can coexist because the more specific routes take precedence over the less specific routes. The catch-all route
/*{filepath}
would not match any requests that match the more specific routes for users. Additionally, the/users/{id}/*{actions}
route would only match requests that have/users/{id}/
as a prefix and would not conflict with the/users/{id}/emails
route since it is more specific.Adding the route
/users/{name}
would break the rules because there are two named parameters ({id}
and{name}
) overlapping in the same path segment/user/
for the same request method. The router would not allow this configuration, as it would introduce ambiguity in route matching.Benefits
Drawbacks
Conclusion
By allowing limited route overlapping and prioritizing more specific routes, Fox could handle a broader range of use cases without significantly impacting performance.