Skip to content

axum 0.8 and wildcard * #3204

Answered by mladedav
frederikhors asked this question in Q&A
Jan 30, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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),
);

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?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@frederikhors
Comment options

Answer selected by jplatte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3203 on January 30, 2025 13:51.