Skip to content

Conflicting routes #3039

Answered by oneslash
oneslash asked this question in Q&A
Discussion options

You must be logged in to vote

I have done a different way, created one handler which handles all PUT /{}*, and inside I match them myself.

#[put("/{tail}*")]
pub async fn handle_put(_: web::Path<String>, req: HttpRequest) -> Result<HttpResponse, Error> {
    let mut path = Path::new(Url::new(req.uri().clone()));
    let mut message = String::new();

    let routes = [
        ("/{bucket}/{object_name}", "bucket and object"),
        ("/{bucket}", "bucket"),
    ];

    for (pattern, description) in &routes {
        if ResourceDef::new(*pattern).capture_match_info(&mut path) {
            match (path.get("bucket"), path.get("object_name")) {
                (Some(bucket), Some(object_name)) if *description == "bucket …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by oneslash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant