Update actix-gcd example to use actix-web 4.1.

pull/18/head
Jim Blandy 2 years ago
parent ef4901665b
commit 268dd00366

1442
actix-gcd/Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -8,5 +8,5 @@ edition = "2018"
# https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "1.0.8"
actix-web = "4.1"
serde = { version = "1.0", features = ["derive"] }

@ -1,6 +1,7 @@
use actix_web::{web, App, HttpResponse, HttpServer};
fn main() {
#[actix_web::main]
async fn main() {
let server = HttpServer::new(|| {
App::new()
.route("/", web::get().to(get_index))
@ -10,10 +11,12 @@ fn main() {
println!("Serving on http://localhost:3000...");
server
.bind("127.0.0.1:3000").expect("error binding server to address")
.run().expect("error running server");
.run()
.await
.expect("error running server");
}
fn get_index() -> HttpResponse {
async fn get_index() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html")
.body(
@ -35,7 +38,7 @@ struct GcdParameters {
m: u64,
}
fn post_gcd(form: web::Form<GcdParameters>) -> HttpResponse {
async fn post_gcd(form: web::Form<GcdParameters>) -> HttpResponse {
if form.n == 0 || form.m == 0 {
return HttpResponse::BadRequest()
.content_type("text/html")

Loading…
Cancel
Save