1
0
mirror of https://github.com/actix/actix-website synced 2024-11-25 17:22:42 +01:00
actix-website/examples/requests/src/urlencoded.rs
2019-06-26 01:27:17 -04:00

24 lines
495 B
Rust

// <urlencoded>
use actix_web::{web, HttpResponse};
use serde::Deserialize;
#[derive(Deserialize)]
struct FormData {
username: String,
}
fn index(form: web::Form<FormData>) -> HttpResponse {
HttpResponse::Ok().body(format!("username: {}", form.username))
}
// </urlencoded>
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::post().to(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}