Skip to content

Misrouting when routing requests for the root path #1098

@SciStarter

Description

@SciStarter

Expected Behavior

A request to "/" should be handled by the "/" handler, not the "/*path" handler

Actual Behavior

The request is handled by the "/*path" handler

Steps to Reproduce the Problem

use poem::{Route, Server, IntoResponse, test::TestClient, get, handler};

#[handler]
async fn handler_a() -> impl IntoResponse {
    "A"
}

#[handler]
async fn handler_b() -> impl IntoResponse {
    "B"
}

#[tokio::main]
async fn main() {
    let routes = Route::new()
        .at("/", handler_a)
        .at("/*path", handler_b);

    let resp = TestClient::new(routes).get("/").send().await;

    // prints out:
    // [src/main.rs:23:5] resp.0.into_body().into_string().await.unwrap() = "B"
    dbg!(resp.0.into_body().into_string().await.unwrap());
}

Specifications

  • Version: 3.1.12
  • Platform: Linux
  • Subsystem: Router

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions