Skip to content
New issue

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

When using nest(some_path, sub_router);, it is impossible to distinguish the trailing / in path. #3233

Open
1 task done
xb284524239 opened this issue Feb 24, 2025 · 1 comment

Comments

@xb284524239
Copy link

  • I have looked for existing issues (including closed) about this

Bug Report

When using nest(some_path, sub_router);, it is impossible to distinguish the trailing / in path.

Version

0.8

Platform

All.

Crates

axum

Description

I tried this code:

    let r1 = Router::new()
        .route("", get(index_page))    // This line of code will cause a compilation error unless it is commented out.
        .route("/", get(index_page))
        .route("/add", get(add_page))
        .route("/list", get(list_page));
    Router::new().nest("/Mall", r1).fallback(get(not_found))

I expected to see this happen:

// http://127.0.0.1/Mall            status: 200, body: "Hello, World!"
// http://127.0.0.1/Mall/           status: 200, body: "Hello, World!"

Instead, this happened:

// http://127.0.0.1/Mall            status: 200, body: "Hello, World!"
// http://127.0.0.1/Mall/           status: 404, body: Page Not Found!

Simply put, I hope that when nesting sub-routes, it can correctly distinguish between two cases: http://127.0.0.1/Mall and http://127.0.0.1/Mall/. However, currently, the Axum framework can only recognize the case of http://127.0.0.1/Mall.

@mladedav
Copy link
Collaborator

This is a duplicate of #2659.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants