// use actix_web::{post, web, App, HttpServer, Result}; use serde::Deserialize; #[derive(Deserialize)] struct Info { username: String, } /// deserialize `Info` from request's body #[post("/submit")] async fn submit(info: web::Json) -> Result { Ok(format!("Welcome {}!", info.username)) } // #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().service(submit)) .bind(("127.0.0.1", 8080))? .run() .await }