oxidecomputer / oxidecomputer/dropshot
Allow overlapping route definitions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 104
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 22
Description
Whether we need this depends on some other architectural decisions. I'm writing this up so I can refer to it elsewhere.
Right now, defining both GET /abc/* and GET /abc/def is an error at startup because the route definitions overlap, and Dropshot would not know which to handler to call when a request matches both routes. There are a couple of ways we could break ties:
- Order of route registration
- Simple to implement (I think? we're already using
BTreeMapfor the route nodes, so we know the insertion order) and to understand - Too easy to accidentally mess up the logic by moving routes around
- Simple to implement (I think? we're already using
- Specificity of matching
- Request to
/abc/defgoes to the exact match because it ranks higher than a wildcard match - While the logic is hidden in the implementation, the idea of match specificity is pretty intuitive. You can only change matching logic by changing the route paths, which is less error-prone than changing it by shuffling things around. However, it has the similar problem that deleting a more specific route can cause a wildcard to start matching requests it didn't match before.
- A little more work to implement, but not too bad. something in here
- Example ranking algorithms
- Request to
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the route-node construction in dropshot/src/router.rs around lines 86-102 and the matching logic around lines 486-515. Review the issue's tradeoffs and related routing examples to determine which tie-breaking behavior the project should adopt. Done means the architectural choice is settled and overlapping definitions can be handled consistently, with matching behavior covered by tests if the project specifies them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100