Add NestedUri (#161)

Fixes https://github.com/tokio-rs/axum/issues/159
This commit is contained in:
David Pedersen
2021-08-08 14:45:31 +02:00
committed by GitHub
parent 8013165908
commit b4bdddf9d2
6 changed files with 86 additions and 2 deletions
+25
View File
@@ -158,3 +158,28 @@ async fn nested_url_extractor() {
.unwrap();
assert_eq!(res.text().await.unwrap(), "/foo/bar/qux");
}
#[tokio::test]
async fn nested_url_nested_extractor() {
let app = nest(
"/foo",
nest(
"/bar",
route(
"/baz",
get(|uri: extract::NestedUri| async move { uri.0.to_string() }),
),
),
);
let addr = run_in_background(app).await;
let client = reqwest::Client::new();
let res = client
.get(format!("http://{}/foo/bar/baz", addr))
.send()
.await
.unwrap();
assert_eq!(res.text().await.unwrap(), "/baz");
}