#2659·axum

Consider changing the behavior of / route when nesting

Author: jplatteCreated Mar 17, 2024Updated Sep 7, 2026
LabelsC-musingsE-hardbreaking changeA-axum

Currently, given a router

rust
let inner = Router::new().route("/", method_router);

and an outer router

  • Router::new().nest("/foo", inner) => only the route /foo exists
  • Router::new().nest("/foo/", inner) => only the route /foo/ exists

It seems like people (me included) generally prefer the first form, but oftentimes expect different behavior (see #2267). We should (re)consider what behavior(s) are reasonable for the upcoming release. Also worth checking: What happens with nest_service?