axum 0.8 and wildcard * #3204
-
With axum before 0.8 I was using this: Router::new().route(
&format!("{}/*value", conf.API_PREFIX),
get(something),
); Now it says me:
What does it mean? Where should I write I opened an issue because I think we should update docs and errors. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Instead of Router::new().route(
&format!("{}/*value", conf.API_PREFIX),
get(something),
); use Router::new().route(
&format!("{}/{{*value}}", conf.API_PREFIX), // Double `{{` and `}}` so that `format!` leaves literal `{` and `}` there
get(something),
);
I'm also not sure how to rephrase the error message. I guess we could write the full segments there, i.e. instead of "segment starting with |
Beta Was this translation helpful? Give feedback.
Instead of
use
Router::route
already has a section on wildcards and I'm not sure how to make it clearer.I'm also not sure how to rephrase the error message. I guess we could write the full segments there, i.e. instead of "segment starting with
*
" we might write "segment*value
" and instead of{*wildcard}
we could write{*value}
in your specific case. Do you think that would help or do you have something else in mind?