2019-06-17 14:34:23 -04:00
|
|
|
// <urlencoded>
|
2019-06-26 01:27:17 -04:00
|
|
|
use actix_web::{web, HttpResponse};
|
|
|
|
use serde::Deserialize;
|
2019-06-17 14:34:23 -04:00
|
|
|
|
2019-06-26 01:27:17 -04:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
struct FormData {
|
|
|
|
username: String,
|
|
|
|
}
|
2019-06-17 14:34:23 -04:00
|
|
|
|
2019-12-29 02:32:47 +09:00
|
|
|
async fn index(form: web::Form<FormData>) -> HttpResponse {
|
2019-06-26 01:27:17 -04:00
|
|
|
HttpResponse::Ok().body(format!("username: {}", form.username))
|
|
|
|
}
|
2019-06-17 14:34:23 -04:00
|
|
|
// </urlencoded>
|
2019-06-26 01:27:17 -04:00
|
|
|
|
2019-12-29 02:32:47 +09:00
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
2019-06-26 01:27:17 -04:00
|
|
|
use actix_web::{App, HttpServer};
|
|
|
|
|
|
|
|
HttpServer::new(|| App::new().route("/", web::post().to(index)))
|
2019-12-29 02:32:47 +09:00
|
|
|
.bind("127.0.0.1:8088")?
|
2019-06-26 01:27:17 -04:00
|
|
|
.run()
|
2019-12-29 02:32:47 +09:00
|
|
|
.await
|
2019-06-26 01:27:17 -04:00
|
|
|
}
|