1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 08:32:20 +01:00

19 lines
362 B
Rust
Raw Normal View History

2019-06-16 23:17:17 -04:00
// <json-one>
use actix_web::{web, App, Result};
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
username: String,
}
/// deserialize `Info` from request's body
fn index(info: web::Json<Info>) -> Result<String> {
Ok(format!("Welcome {}!", info.username))
}
pub fn main() {
App::new().route("/", web::get().to(index));
}
// </json-one>