mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Support wildcards in typed paths (#1003)
* Support wildcards in typed paths * changelog
This commit is contained in:
@@ -297,14 +297,10 @@ fn parse_path(path: &LitStr) -> syn::Result<Vec<Segment>> {
|
||||
path.value()
|
||||
.split('/')
|
||||
.map(|segment| {
|
||||
if segment.contains('*') {
|
||||
return Err(syn::Error::new_spanned(
|
||||
path,
|
||||
"`typed_path` cannot contain wildcards",
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(capture) = segment.strip_prefix(':') {
|
||||
if let Some(capture) = segment
|
||||
.strip_prefix(':')
|
||||
.or_else(|| segment.strip_prefix('*'))
|
||||
{
|
||||
Ok(Segment::Capture(capture.to_owned(), path.span()))
|
||||
} else {
|
||||
Ok(Segment::Static(segment.to_owned()))
|
||||
|
||||
Reference in New Issue
Block a user