We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Having ? at the end of a parameter name will mark it as optional.
?
Any characters that precede it will also be considered part of the same optional segment, excluding /.
/
This is less explicit than a 'grouping' syntax, but should be just as easy to understand.
/users/{id?}
/users
/users/{id}
/users/123
/users/123/456
/files/{*path?}
/files
/files/{*path}
/files/report.pdf
/files/images/beach.jpg
/users/{user}/profile.{ext?}
/users/{user}/profile
/users/{user}/profile.{ext}
/users/{user}
/users/{user}/profile.
/users/{user}/profile.jpg
/users/{user}/profile.jpg.png
/release/v{major}.{minor?}.{patch?}
/release/v{major}
/release/v{major}.{minor}
/release/v{major}.{minor}.{patch}
/release/v4
/release/v4.
/release/v4.1
/release/v4.1.
/release/v4.1.4
/release/v4.1.4.5
All optional values will have to be returned an Option<&str>.
Option<&str>
Should support constraints for all types:
/users/{id?:constraint}
/files/{*path?:constraint}
How we decide to handle segment checks is TBD.
Optionals MUST come at the end of a path, segment or section.
We MAY allow multiple chained optionals, undecided.
We won't support defaults in the route. Just use .unwrap_or in your framework of choice.
.unwrap_or
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Optionals
Having
?
at the end of a parameter name will mark it as optional.Any characters that precede it will also be considered part of the same optional segment, excluding
/
.This is less explicit than a 'grouping' syntax, but should be just as easy to understand.
Types
Dynamic Segment
/users/{id?}
Equivalent
/users
/users/{id}
Match
/users
-> OK/users/123
-> OK/users/123/456
-> ERRWildcard Segment(s)
/files/{*path?}
Equivalent
/files
/files/{*path}
Match
/files
-> OK/files/report.pdf
-> OK/files/images/beach.jpg
-> OKInline Dynamic Section
/users/{user}/profile.{ext?}
Equivalent
/users/{user}/profile
/users/{user}/profile.{ext}
Match
/users/{user}
-> ERR/users/{user}/profile
-> OK/users/{user}/profile.
-> ERR/users/{user}/profile.jpg
-> OK/users/{user}/profile.jpg.png
-> OK, BUT WEIRDInline Dynamic Section(s)
/release/v{major}.{minor?}.{patch?}
Equivalent
/release/v{major}
/release/v{major}.{minor}
/release/v{major}.{minor}.{patch}
Match
/release/v4
-> OK/release/v4.
-> ERR/release/v4.1
-> OK/release/v4.1.
-> ERR/release/v4.1.4
-> OK/release/v4.1.4.5
-> OK, BUT WEIRDParameters
All optional values will have to be returned an
Option<&str>
.Constraints
Should support constraints for all types:
/users/{id?:constraint}
/files/{*path?:constraint}
How we decide to handle segment checks is TBD.
Limitations
Optionals MUST come at the end of a path, segment or section.
We MAY allow multiple chained optionals, undecided.
We won't support defaults in the route. Just use
.unwrap_or
in your framework of choice.Prior Art
Changes Needed
The text was updated successfully, but these errors were encountered: