1
0
mirror of https://github.com/actix/actix-website synced 2025-03-20 06:35:18 +01:00
Ralph Ursprung e4eb883a0d fix minor typo in output of extractors example (#114)
this has no effect on the actual functionality, it just fixes a typo
which was hard to overlook :)
2019-09-30 03:35:26 +09:00

32 lines
614 B
Rust

// <multi>
use actix_web::web;
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
username: String,
}
fn index((path, query): (web::Path<(u32, String)>, web::Query<Info>)) -> String {
format!(
"Welcome {}, friend {}, userid {}!",
query.username, path.1, path.0
)
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/users/{userid}/{friend}", // <- define path parameters
web::get().to(index),
)
})
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}
// </multi>