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

22 lines
457 B
Rust
Raw Normal View History

2018-05-24 10:13:55 -07:00
// <path>
2019-06-16 20:19:25 -04:00
use actix_web::{http::Method, web, App, Result};
use serde::Deserialize;
2018-05-24 10:13:55 -07:00
#[derive(Deserialize)]
struct Info {
username: String,
}
// extract path info using serde
2019-06-16 20:19:25 -04:00
fn index(info: web::Path<Info>) -> Result<String> {
2018-05-24 10:13:55 -07:00
Ok(format!("Welcome {}!", info.username))
}
fn main() {
let app = App::new().resource(
"/{username}/index.html", // <- define path parameters
|r| r.method(Method::GET).with(index),
);
}
// </path>