1
0
mirror of https://github.com/actix/actix-website synced 2025-02-09 06:45:37 +01:00

16 lines
353 B
Rust
Raw Normal View History

2018-05-24 10:13:55 -07:00
// <path>
2019-06-17 02:08:42 -04:00
use actix_web::{web, App, Result};
2018-05-24 10:13:55 -07:00
// extract path info using serde
2019-06-17 02:08:42 -04:00
fn index(info: web::Path<(String, u32)>) -> Result<String> {
2018-05-24 10:13:55 -07:00
Ok(format!("Welcome {}! id: {}", info.0, info.1))
}
pub fn main() {
2019-06-17 02:08:42 -04:00
App::new().route(
2018-05-24 10:13:55 -07:00
"/{username}/{id}/index.html", // <- define path parameters
2019-06-17 02:08:42 -04:00
web::get().to(index),
2018-05-24 10:13:55 -07:00
);
}
// </path>