Implement path extractor (#124)

Fixes #42
This commit is contained in:
Sunli
2021-08-06 10:17:57 +02:00
committed by GitHub
parent 2be79168d8
commit 9fdbd42fba
14 changed files with 871 additions and 66 deletions
+1 -7
View File
@@ -29,14 +29,8 @@ async fn main() {
.unwrap();
}
async fn greet(params: extract::UrlParamsMap) -> impl IntoResponse {
let name = params
.get("name")
.expect("`name` will be there if route was matched")
.to_string();
async fn greet(extract::Path(name): extract::Path<String>) -> impl IntoResponse {
let template = HelloTemplate { name };
HtmlTemplate(template)
}