1
0
mirror of https://github.com/actix/actix-website synced 2024-11-26 01:32:42 +01:00
actix-website/examples/requests/src/urlencoded.rs

24 lines
495 B
Rust
Raw Normal View History

2019-06-17 20:34:23 +02:00
// <urlencoded>
2019-06-26 07:27:17 +02:00
use actix_web::{web, HttpResponse};
use serde::Deserialize;
2019-06-17 20:34:23 +02:00
2019-06-26 07:27:17 +02:00
#[derive(Deserialize)]
struct FormData {
username: String,
}
2019-06-17 20:34:23 +02:00
2019-06-26 07:27:17 +02:00
fn index(form: web::Form<FormData>) -> HttpResponse {
HttpResponse::Ok().body(format!("username: {}", form.username))
}
2019-06-17 20:34:23 +02:00
// </urlencoded>
2019-06-26 07:27:17 +02:00
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();
}