From c21fcae0878de0446b38668b0a2072cc8811a6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=9D=A8=E5=B8=86?= <39647285+leno23@users.noreply.github.com> Date: Sun, 17 May 2026 16:51:06 +0800 Subject: [PATCH] docs(axum): document that path must start with `/` in `Router::route` (#3771) Co-authored-by: Cursor --- axum/src/docs/routing/route.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/axum/src/docs/routing/route.md b/axum/src/docs/routing/route.md index bb4ac530..d8b1fc75 100644 --- a/axum/src/docs/routing/route.md +++ b/axum/src/docs/routing/route.md @@ -176,4 +176,6 @@ let app = Router::new() The static route `/foo` and the dynamic route `/{key}` are not considered to overlap and `/foo` will take precedence. -Also panics if `path` is empty. +Also panics if `path` is empty or does not start with `/` (for example `"Cargo.lock"`). +When nesting routers with [`Router::nest`](crate::Router::nest), nested paths are still +relative segments and must start with `/` (use `"/Cargo.lock"` rather than `"Cargo.lock"`).