mirror of
https://github.com/actix/actix-website
synced 2025-02-02 12:19:04 +01:00
25 lines
527 B
Rust
25 lines
527 B
Rust
// <urlencoded>
|
|
use actix_web::{post, web, HttpResponse};
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
struct FormData {
|
|
username: String,
|
|
}
|
|
|
|
#[post("/")]
|
|
async fn index(form: web::Form<FormData>) -> HttpResponse {
|
|
HttpResponse::Ok().body(format!("username: {}", form.username))
|
|
}
|
|
// </urlencoded>
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
use actix_web::{App, HttpServer};
|
|
|
|
HttpServer::new(|| App::new().service(index))
|
|
.bind(("127.0.0.1", 8080))?
|
|
.run()
|
|
.await
|
|
}
|