Make it more obvious that NEST_TAIL_PARAM is reserved (#836)

This commit is contained in:
David Pedersen 2022-03-06 17:01:14 +01:00 committed by GitHub
parent a438e6b106
commit b05a5c6dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -99,8 +99,8 @@ impl<B> fmt::Debug for Router<B> {
}
}
pub(crate) const NEST_TAIL_PARAM: &str = "axum_nest";
const NEST_TAIL_PARAM_CAPTURE: &str = "/*axum_nest";
pub(crate) const NEST_TAIL_PARAM: &str = "__private__axum_nest_tail_param";
const NEST_TAIL_PARAM_CAPTURE: &str = "/*__private__axum_nest_tail_param";
impl<B> Router<B>
where

View file

@ -525,7 +525,10 @@ async fn route_layer() {
#[tokio::test]
#[should_panic(
expected = "Invalid route: insertion failed due to conflict with previously registered route: /*axum_nest. Note that `nest(\"/\", _)` conflicts with all routes. Use `Router::fallback` instead"
expected = "Invalid route: insertion failed due to conflict with previously registered \
route: /*__private__axum_nest_tail_param. \
Note that `nest(\"/\", _)` conflicts with all routes. \
Use `Router::fallback` instead"
)]
async fn good_error_message_if_using_nest_root() {
let app = Router::new()
@ -536,7 +539,10 @@ async fn good_error_message_if_using_nest_root() {
#[tokio::test]
#[should_panic(
expected = "Invalid route: insertion failed due to conflict with previously registered route: /*axum_nest. Note that `nest(\"/\", _)` conflicts with all routes. Use `Router::fallback` instead"
expected = "Invalid route: insertion failed due to conflict with previously registered \
route: /*__private__axum_nest_tail_param. \
Note that `nest(\"/\", _)` conflicts with all routes. \
Use `Router::fallback` instead"
)]
async fn good_error_message_if_using_nest_root_when_merging() {
let one = Router::new().nest("/", get(|| async {}));