mirror of
https://github.com/actix/actix-website
synced 2025-02-13 08:32:20 +01:00
19 lines
362 B
Rust
19 lines
362 B
Rust
|
// <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>
|