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