From f8e3430d1a2139771aac9afa8a83402b4c82c4ec Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 00:38:07 +0900 Subject: [PATCH 01/23] Point to v2 docs --- content/docs/errors.md | 8 ++++---- content/docs/extractors.md | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/content/docs/errors.md b/content/docs/errors.md index 6dd697a..d5e0f15 100644 --- a/content/docs/errors.md +++ b/content/docs/errors.md @@ -134,9 +134,9 @@ This is a basic example using `middleware::Logger`: {{< include-example example="errors" file="logging.rs" section="logging" >}} -[actixerror]: https://docs.rs/actix-web/1.0.2/actix_web/error/struct.Error.html -[errorhelpers]: https://docs.rs/actix-web/1.0.2/actix_web/trait.ResponseError.html +[actixerror]: https://docs.rs/actix-web/2/actix_web/error/struct.Error.html +[errorhelpers]: https://docs.rs/actix-web/2/actix_web/trait.ResponseError.html [failure]: https://github.com/rust-lang-nursery/failure -[responseerror]: https://docs.rs/actix-web/1.0.2/actix_web/error/trait.ResponseError.html -[responseerrorimpls]: https://docs.rs/actix-web/1.0.2/actix_web/error/trait.ResponseError.html#foreign-impls +[responseerror]: https://docs.rs/actix-web/2/actix_web/error/trait.ResponseError.html +[responseerrorimpls]: https://docs.rs/actix-web/2/actix_web/error/trait.ResponseError.html#foreign-impls [stderror]: https://doc.rust-lang.org/std/error/trait.Error.html diff --git a/content/docs/extractors.md b/content/docs/extractors.md index e77adfd..0bd1301 100644 --- a/content/docs/extractors.md +++ b/content/docs/extractors.md @@ -127,13 +127,13 @@ number of requests processed per thread. A proper implementation would use `Arc` > request handling processes would block. If you need to share or update some state > from multiple threads, consider using the [actix][actix] actor system. -[pathstruct]: (https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.Path.html -[querystruct]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Query.html -[jsonstruct]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Json.html -[jsonconfig]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.JsonConfig.html -[formconfig]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.FormConfig.html -[datastruct]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Data.html -[stringexample]: https://docs.rs/actix-web/1.0.2/actix_web/trait.FromRequest.html#example-2 -[bytesexample]: https://docs.rs/actix-web/1.0.2/actix_web/trait.FromRequest.html#example-4 -[payloadexample]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Payload.html +[pathstruct]: https://docs.rs/actix-web/2/actix_web/dev/struct.Path.html +[querystruct]: https://docs.rs/actix-web/2/actix_web/web/struct.Query.html +[jsonstruct]: https://docs.rs/actix-web/2/actix_web/web/struct.Json.html +[jsonconfig]: https://docs.rs/actix-web/2/actix_web/web/struct.JsonConfig.html +[formconfig]: https://docs.rs/actix-web/2/actix_web/web/struct.FormConfig.html +[datastruct]: https://docs.rs/actix-web/2/actix_web/web/struct.Data.html +[stringexample]: https://docs.rs/actix-web/2/actix_web/trait.FromRequest.html#example-2 +[bytesexample]: https://docs.rs/actix-web/2/actix_web/trait.FromRequest.html#example-4 +[payloadexample]: https://docs.rs/actix-web/2/actix_web/web/struct.Payload.html [actix]: https://actix.github.io/actix/actix/ From 67c0360864bfe0b46efe512067b98a4b25923557 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:15:22 +0900 Subject: [PATCH 02/23] Update application examples to v2 --- examples/application/Cargo.toml | 3 ++- examples/application/src/app.rs | 5 +++-- examples/application/src/combine.rs | 8 ++++---- examples/application/src/config.rs | 8 ++++---- examples/application/src/scope.rs | 7 ++++--- examples/application/src/state.rs | 22 +++++++++++----------- examples/application/src/vh.rs | 8 ++++---- 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/examples/application/Cargo.toml b/examples/application/Cargo.toml index 0316c80..4f7e08b 100644 --- a/examples/application/Cargo.toml +++ b/examples/application/Cargo.toml @@ -5,4 +5,5 @@ edition = "2018" workspace = "../" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/application/src/app.rs b/examples/application/src/app.rs index 7dadc5c..dafb372 100644 --- a/examples/application/src/app.rs +++ b/examples/application/src/app.rs @@ -1,12 +1,13 @@ // use actix_web::{web, App, Responder}; -fn index() -> impl Responder { +async fn index() -> impl Responder { "Hello world!" } #[rustfmt::skip] -pub fn main() { +#[actix_rt::main] +async fn main() { App::new().service( web::scope("/app") .route("/index.html", web::get().to(index))); diff --git a/examples/application/src/combine.rs b/examples/application/src/combine.rs index 0ce5a88..ce11025 100644 --- a/examples/application/src/combine.rs +++ b/examples/application/src/combine.rs @@ -5,7 +5,8 @@ struct State1; struct State2; #[rustfmt::skip] -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service( @@ -17,9 +18,8 @@ pub fn main() { .data(State2) .route("/", web::to(|| HttpResponse::Ok()))) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/application/src/config.rs b/examples/application/src/config.rs index 6d1b9a3..6051dd6 100644 --- a/examples/application/src/config.rs +++ b/examples/application/src/config.rs @@ -19,16 +19,16 @@ fn config(cfg: &mut web::ServiceConfig) { ); } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .configure(config) .service(web::scope("/api").configure(scoped_config)) .route("/", web::get().to(|| HttpResponse::Ok().body("/"))) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/application/src/scope.rs b/examples/application/src/scope.rs index b9c5742..84a7087 100644 --- a/examples/application/src/scope.rs +++ b/examples/application/src/scope.rs @@ -1,12 +1,13 @@ use actix_web::{web, App, HttpRequest, Responder}; -fn show_users(_req: HttpRequest) -> impl Responder { - unimplemented!() +async fn show_users(_req: HttpRequest) -> impl Responder { + "unimplemented!" } #[rustfmt::skip] // -pub fn main() { +#[actix_rt::main] +async fn main() { App::new() .service( web::scope("/users") diff --git a/examples/application/src/state.rs b/examples/application/src/state.rs index c2a7abd..2bb5a0e 100644 --- a/examples/application/src/state.rs +++ b/examples/application/src/state.rs @@ -7,7 +7,7 @@ struct AppState { app_name: String, } -fn index(data: web::Data) -> String { +async fn index(data: web::Data) -> String { let app_name = &data.app_name; // <- get app_name format!("Hello {}!", app_name) // <- response with app_name @@ -19,7 +19,7 @@ struct AppStateWithCounter { counter: Mutex, // <- Mutex is necessary to mutate safely across threads } -fn _index(data: web::Data) -> String { +async fn _index(data: web::Data) -> String { let mut counter = data.counter.lock().unwrap(); // <- get counter's MutexGuard *counter += 1; // <- access counter inside MutexGuard @@ -28,25 +28,26 @@ fn _index(data: web::Data) -> String { // // -fn _main() { +#[actix_rt::main] +async fn _main() -> std::io::Result<()> { let counter = web::Data::new(AppStateWithCounter { counter: Mutex::new(0), }); HttpServer::new(move || { // move counter into the closure App::new() - .register_data(counter.clone()) // <- register the created data + .app_data(counter.clone()) // <- register the created data .route("/", web::get().to(_index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .data(AppState { @@ -54,9 +55,8 @@ pub fn main() { }) .route("/", web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/application/src/vh.rs b/examples/application/src/vh.rs index bd8e34e..d1d6c82 100644 --- a/examples/application/src/vh.rs +++ b/examples/application/src/vh.rs @@ -1,7 +1,8 @@ use actix_web::{guard, web, App, HttpResponse, HttpServer}; // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service( @@ -16,9 +17,8 @@ pub fn main() { ) .route("/", web::to(|| HttpResponse::Ok())) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 299ee6e3526e790ee0f039f950c5eb41a8e4fe9a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:16:54 +0900 Subject: [PATCH 03/23] Update application links to v2 --- content/docs/application.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/application.md b/content/docs/application.md index 4ba4f27..a79f949 100644 --- a/content/docs/application.md +++ b/content/docs/application.md @@ -126,6 +126,6 @@ Each `ServiceConfig` can have it's own `data`, `routes`, and `services` [usingappprefix]: /docs/url-dispatch/index.html#using-an-application-prefix-to-compose-applications [stateexample]: https://github.com/actix/examples/blob/master/state/src/main.rs -[guardtrait]: https://docs.rs/actix-web/1.0.2/actix_web/guard/trait.Guard.html -[guardfuncs]: https://docs.rs/actix-web/1.0.2/actix_web/guard/index.html#functions -[guardheader]: ((https://docs.rs/actix-web/1.0.2/actix_web/guard/fn.Header.html +[guardtrait]: https://docs.rs/actix-web/2/actix_web/guard/trait.Guard.html +[guardfuncs]: https://docs.rs/actix-web/2/actix_web/guard/index.html#functions +[guardheader]: https://docs.rs/actix-web/2/actix_web/guard/fn.Header.html From 1e5f5ecf8bb5072331fcd8ad10bec333d509777d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:21:10 +0900 Subject: [PATCH 04/23] Update autoreload example to v2 --- examples/autoreload/Cargo.toml | 3 ++- examples/autoreload/src/main.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/autoreload/Cargo.toml b/examples/autoreload/Cargo.toml index 55b4b62..1561236 100644 --- a/examples/autoreload/Cargo.toml +++ b/examples/autoreload/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" listenfd = "0.3" diff --git a/examples/autoreload/src/main.rs b/examples/autoreload/src/main.rs index 42ed302..3ceff63 100644 --- a/examples/autoreload/src/main.rs +++ b/examples/autoreload/src/main.rs @@ -2,20 +2,21 @@ use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use listenfd::ListenFd; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Hello World!" } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { let mut listenfd = ListenFd::from_env(); let mut server = HttpServer::new(|| App::new().route("/", web::get().to(index))); server = if let Some(l) = listenfd.take_tcp_listener(0).unwrap() { - server.listen(l).unwrap() + server.listen(l)? } else { - server.bind("127.0.0.1:3000").unwrap() + server.bind("127.0.0.1:3000")? }; - server.run().unwrap(); + server.run().await } // From 66c3bd87295c39e67f15a57adeb95d4bb1ec8c5d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:24:52 +0900 Subject: [PATCH 05/23] Update easu-form-handling example --- examples/easy-form-handling/Cargo.toml | 3 ++- examples/easy-form-handling/src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/easy-form-handling/Cargo.toml b/examples/easy-form-handling/Cargo.toml index bbf8d22..1af8b96 100644 --- a/examples/easy-form-handling/Cargo.toml +++ b/examples/easy-form-handling/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" serde = "1.0" diff --git a/examples/easy-form-handling/src/main.rs b/examples/easy-form-handling/src/main.rs index 84f577a..1bc63f4 100644 --- a/examples/easy-form-handling/src/main.rs +++ b/examples/easy-form-handling/src/main.rs @@ -8,25 +8,25 @@ struct Register { country: String, } -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok() .content_type("text/html; charset=utf-8") .body(include_str!("../static/form.html")) } -fn register(form: web::Form) -> impl Responder { +async fn register(form: web::Form) -> impl Responder { format!("Hello {} from {}!", form.username, form.country) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(index)) .route("/register", web::post().to(register)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From de7c7d3aed02e9e48b1a1864f05b738ad3ac9404 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:29:03 +0900 Subject: [PATCH 06/23] Remove unnecessary dependency --- examples/extractors/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/extractors/Cargo.toml b/examples/extractors/Cargo.toml index 8cc6c12..a455806 100644 --- a/examples/extractors/Cargo.toml +++ b/examples/extractors/Cargo.toml @@ -7,5 +7,4 @@ edition = "2018" actix-web = "2.0" actix-rt = "1.0" serde = "1.0" -futures = "0.3" serde_json = "1.0" From 37bd5e5da26887b9fceb34b46b3df4b577f7a1e1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:32:43 +0900 Subject: [PATCH 07/23] Update flexible-responders --- examples/flexible-responders/Cargo.toml | 3 ++- examples/flexible-responders/src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/flexible-responders/Cargo.toml b/examples/flexible-responders/Cargo.toml index 5aec859..8a29135 100644 --- a/examples/flexible-responders/Cargo.toml +++ b/examples/flexible-responders/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" serde = "1.0" diff --git a/examples/flexible-responders/src/main.rs b/examples/flexible-responders/src/main.rs index fd56f1e..0237fc3 100644 --- a/examples/flexible-responders/src/main.rs +++ b/examples/flexible-responders/src/main.rs @@ -7,23 +7,23 @@ struct Measurement { temperature: f32, } -fn hello_world() -> impl Responder { +async fn hello_world() -> impl Responder { "Hello World!" } -fn current_temperature() -> impl Responder { +async fn current_temperature() -> impl Responder { web::Json(Measurement { temperature: 42.3 }) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").to(hello_world)) .service(web::resource("/temp").to(current_temperature)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From e018ce42782ad7c09973ffb06192e0645d4a0cca Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:33:19 +0900 Subject: [PATCH 08/23] Update getting-started --- examples/getting-started/Cargo.toml | 3 ++- examples/getting-started/src/main.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/getting-started/Cargo.toml b/examples/getting-started/Cargo.toml index 1632b62..fee4ef7 100644 --- a/examples/getting-started/Cargo.toml +++ b/examples/getting-started/Cargo.toml @@ -5,4 +5,5 @@ edition = "2018" workspace = "../" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/getting-started/src/main.rs b/examples/getting-started/src/main.rs index 8208bae..107788b 100644 --- a/examples/getting-started/src/main.rs +++ b/examples/getting-started/src/main.rs @@ -1,11 +1,11 @@ // use actix_web::{web, App, HttpResponse, HttpServer, Responder}; -fn index() -> impl Responder { +async fn index() -> impl Responder { HttpResponse::Ok().body("Hello world!") } -fn index2() -> impl Responder { +async fn index2() -> impl Responder { HttpResponse::Ok().body("Hello world again!") } // @@ -14,21 +14,21 @@ fn index2() -> impl Responder { use actix_web::get; #[get("/hello")] -fn index3() -> impl Responder { +async fn index3() -> impl Responder { HttpResponse::Ok().body("Hey there!") } // //
-fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(index)) .route("/again", web::get().to(index2)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //
From 9da187a36cc2756e45a8e51f26e333ca2ae35771 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:37:19 +0900 Subject: [PATCH 09/23] Update http2 --- content/docs/http2.md | 6 +++--- examples/http2/Cargo.toml | 3 ++- examples/http2/src/main.rs | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/content/docs/http2.md b/content/docs/http2.md index d64e395..c93c1e1 100644 --- a/content/docs/http2.md +++ b/content/docs/http2.md @@ -13,11 +13,11 @@ weight: 250 > Currently, only `rust-openssl` has support. `alpn` negotiation requires enabling the feature. When enabled, `HttpServer` provides the -[bind_ssl][bindssl] method. +[bind_openssl][bindopenssl] method. ```toml [dependencies] -actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["ssl"] } +actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["openssl"] } openssl = { version = "0.10", features = ["v110"] } ``` {{< include-example example="http2" file="main.rs" section="main" >}} @@ -30,6 +30,6 @@ connection and tls connection. [rfc section 3.4][rfcsection34]. [rfcsection32]: https://http2.github.io/http2-spec/#rfc.section.3.2 [rfcsection34]: https://http2.github.io/http2-spec/#rfc.section.3.4 -[bindssl]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind_ssl +[bindopenssl]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind_openssl [tlsalpn]: https://tools.ietf.org/html/rfc7301 [examples]: https://github.com/actix/examples/tree/master/tls diff --git a/examples/http2/Cargo.toml b/examples/http2/Cargo.toml index 5749e20..c9a0d58 100644 --- a/examples/http2/Cargo.toml +++ b/examples/http2/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = { version = "1.0", features = ["ssl"] } +actix-web = { version = "2.0", features = ["openssl"] } +actix-rt = "1.0" openssl = { version = "0.10", features = ["v110"] } diff --git a/examples/http2/src/main.rs b/examples/http2/src/main.rs index a985211..3dc8599 100644 --- a/examples/http2/src/main.rs +++ b/examples/http2/src/main.rs @@ -2,11 +2,12 @@ use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Hello." } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { // load ssl keys // to create a self-signed temporary cert for testing: // `openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'` @@ -17,9 +18,8 @@ fn main() { builder.set_certificate_chain_file("cert.pem").unwrap(); HttpServer::new(|| App::new().route("/", web::get().to(index))) - .bind_ssl("127.0.0.1:8088", builder) - .unwrap() + .bind_openssl("127.0.0.1:8088", builder)? .run() - .unwrap(); + .await } // From 94c8c843b165099853c84c5fff94e9812633397e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:38:51 +0900 Subject: [PATCH 10/23] Update main-example --- examples/main-example/Cargo.toml | 3 ++- examples/main-example/src/main.rs | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/main-example/Cargo.toml b/examples/main-example/Cargo.toml index 03e0327..10e38ec 100644 --- a/examples/main-example/Cargo.toml +++ b/examples/main-example/Cargo.toml @@ -4,4 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/main-example/src/main.rs b/examples/main-example/src/main.rs index 11f7025..004ec57 100644 --- a/examples/main-example/src/main.rs +++ b/examples/main-example/src/main.rs @@ -1,20 +1,20 @@ // use actix_web::{web, App, HttpRequest, HttpServer, Responder}; -fn greet(req: HttpRequest) -> impl Responder { +async fn greet(req: HttpRequest) -> impl Responder { let name = req.match_info().get("name").unwrap_or("World"); format!("Hello {}!", &name) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(greet)) .route("/{name}", web::get().to(greet)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 789cb0fd1aa3fc3b27f4381748da161486874447 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:03:17 +0900 Subject: [PATCH 11/23] Update middleware --- content/docs/middleware.md | 14 ++++----- examples/middleware/Cargo.toml | 9 +++--- examples/middleware/src/default_headers.rs | 8 ++--- examples/middleware/src/errorhandler.rs | 8 ++--- examples/middleware/src/logger.rs | 8 ++--- examples/middleware/src/main.rs | 35 ++++++++++++++-------- examples/middleware/src/user_sessions.rs | 10 +++---- examples/middleware/src/wrap_fn.rs | 9 ++++-- 8 files changed, 57 insertions(+), 44 deletions(-) diff --git a/content/docs/middleware.md b/content/docs/middleware.md index 7bea23e..cdd74b5 100644 --- a/content/docs/middleware.md +++ b/content/docs/middleware.md @@ -127,11 +127,11 @@ into a response. {{< include-example example="middleware" file="errorhandler.rs" section="error-handler" >}} -[sessionobj]: https://docs.rs/actix-session/0.1.1/actix_session/struct.Session.html -[requestsession]: https://docs.rs/actix-session/0.1.1/actix_session/struct.Session.html -[cookiesession]: https://docs.rs/actix-session/0.1.1/actix_session/struct.CookieSession.html -[actixsession]: https://docs.rs/actix-session/0.1.1/actix_session/ +[sessionobj]: https://docs.rs/actix-session/0.3.0/actix_session/struct.Session.html +[requestsession]: https://docs.rs/actix-session/0.3.0/actix_session/struct.Session.html +[cookiesession]: https://docs.rs/actix-session/0.3.0/actix_session/struct.CookieSession.html +[actixsession]: https://docs.rs/actix-session/0.3.0/actix_session/ [envlogger]: https://docs.rs/env_logger/*/env_logger/ -[servicetrait]: https://docs.rs/actix-web/1.0.2/actix_web/dev/trait.Service.html -[transformtrait]: https://docs.rs/actix-web/1.0.2/actix_web/dev/trait.Transform.html -[wrap_fn]: https://docs.rs/actix-web/1.0.5/actix_web/struct.App.html#method.wrap_fn +[servicetrait]: https://docs.rs/actix-web/2/actix_web/dev/trait.Service.html +[transformtrait]: https://docs.rs/actix-web/2/actix_web/dev/trait.Transform.html +[wrap_fn]: https://docs.rs/actix-web/2/actix_web/struct.App.html#method.wrap_fn diff --git a/examples/middleware/Cargo.toml b/examples/middleware/Cargo.toml index 3448545..dece5a1 100644 --- a/examples/middleware/Cargo.toml +++ b/examples/middleware/Cargo.toml @@ -4,8 +4,9 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" -actix-service = "0.4" -actix-session = "0.1" -futures = "0.1" +actix-web = "2.0" +actix-rt = "1.0" +actix-service = "1.0" +actix-session = "0.3" +futures = "0.3.1" env_logger = "0.6" diff --git a/examples/middleware/src/default_headers.rs b/examples/middleware/src/default_headers.rs index d998a15..f71377d 100644 --- a/examples/middleware/src/default_headers.rs +++ b/examples/middleware/src/default_headers.rs @@ -1,7 +1,8 @@ // use actix_web::{http, middleware, HttpResponse}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -16,9 +17,8 @@ pub fn main() { ), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/middleware/src/errorhandler.rs b/examples/middleware/src/errorhandler.rs index dacef6e..aa16b28 100644 --- a/examples/middleware/src/errorhandler.rs +++ b/examples/middleware/src/errorhandler.rs @@ -10,7 +10,8 @@ fn render_500(mut res: dev::ServiceResponse) -> Result std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -25,9 +26,8 @@ pub fn main() { .route(web::head().to(|| HttpResponse::MethodNotAllowed())), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/middleware/src/logger.rs b/examples/middleware/src/logger.rs index 254e5d1..fd991d2 100644 --- a/examples/middleware/src/logger.rs +++ b/examples/middleware/src/logger.rs @@ -2,7 +2,8 @@ use actix_web::middleware::Logger; use env_logger; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; std::env::set_var("RUST_LOG", "actix_web=info"); @@ -13,9 +14,8 @@ pub fn main() { .wrap(Logger::default()) .wrap(Logger::new("%a %{User-Agent}i")) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/middleware/src/main.rs b/examples/middleware/src/main.rs index ba97d1d..50018cd 100644 --- a/examples/middleware/src/main.rs +++ b/examples/middleware/src/main.rs @@ -5,10 +5,13 @@ pub mod user_sessions; pub mod wrap_fn; // +use std::pin::Pin; +use std::task::{Context, Poll}; + use actix_service::{Service, Transform}; use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error}; -use futures::future::{ok, FutureResult}; -use futures::{Future, Poll}; +use futures::future::{ok, Ready}; +use futures::Future; // There are two steps in middleware processing. // 1. Middleware initialization, middleware factory gets called with @@ -30,7 +33,7 @@ where type Error = Error; type InitError = (); type Transform = SayHiMiddleware; - type Future = FutureResult; + type Future = Ready>; fn new_transform(&self, service: S) -> Self::Future { ok(SayHiMiddleware { service }) @@ -50,34 +53,40 @@ where type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; - type Future = Box>; + type Future = Pin>>>; - fn poll_ready(&mut self) -> Poll<(), Self::Error> { - self.service.poll_ready() + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.service.poll_ready(cx) } fn call(&mut self, req: ServiceRequest) -> Self::Future { println!("Hi from start. You requested: {}", req.path()); - Box::new(self.service.call(req).and_then(|res| { + let fut = self.service.call(req); + + Box::pin(async move { + let res = fut.await?; + println!("Hi from response"); Ok(res) - })) + }) } } // -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { App::new().wrap(SayHi).service( web::resource("/") - .to(|| "Hello, middleware! Check the console where the server is run."), + .to(|| async { + "Hello, middleware! Check the console where the server is run." + }), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } diff --git a/examples/middleware/src/user_sessions.rs b/examples/middleware/src/user_sessions.rs index b4f99ff..261f5c2 100644 --- a/examples/middleware/src/user_sessions.rs +++ b/examples/middleware/src/user_sessions.rs @@ -2,7 +2,7 @@ use actix_session::{CookieSession, Session}; use actix_web::{web, App, Error, HttpResponse, HttpServer}; -pub fn index(session: Session) -> Result { +async fn index(session: Session) -> Result { // access session data if let Some(count) = session.get::("counter")? { session.set("counter", count + 1)?; @@ -16,7 +16,8 @@ pub fn index(session: Session) -> Result { ))) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .wrap( @@ -25,9 +26,8 @@ pub fn main() { ) .service(web::resource("/").to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/middleware/src/wrap_fn.rs b/examples/middleware/src/wrap_fn.rs index 18c139e..a3f8f0a 100644 --- a/examples/middleware/src/wrap_fn.rs +++ b/examples/middleware/src/wrap_fn.rs @@ -1,9 +1,10 @@ // use actix_service::Service; use actix_web::{web, App}; -use futures::future::Future; +use futures::future::FutureExt; -fn main() { +#[actix_rt::main] +async fn main() { let app = App::new() .wrap_fn(|req, srv| { println!("Hi from start. You requested: {}", req.path()); @@ -14,7 +15,9 @@ fn main() { }) .route( "/index.html", - web::get().to(|| "Hello, middleware!"), + web::get().to(|| async { + "Hello, middleware!" + }), ); } // From 8594212533e5faa07ab0e8578495b21f8b7b0804 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:05:27 +0900 Subject: [PATCH 12/23] Update powerful-extractors --- examples/powerful-extractors/Cargo.toml | 3 ++- examples/powerful-extractors/src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/powerful-extractors/Cargo.toml b/examples/powerful-extractors/Cargo.toml index 5f20144..1e84b9e 100644 --- a/examples/powerful-extractors/Cargo.toml +++ b/examples/powerful-extractors/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" serde = "1.0" diff --git a/examples/powerful-extractors/src/main.rs b/examples/powerful-extractors/src/main.rs index 5d80d7f..7005554 100644 --- a/examples/powerful-extractors/src/main.rs +++ b/examples/powerful-extractors/src/main.rs @@ -20,25 +20,25 @@ fn store_in_db(timestamp: f64, kind: &str, tags: &[String]) -> Event { } } -fn capture_event(evt: web::Json) -> impl Responder { +async fn capture_event(evt: web::Json) -> impl Responder { let new_event = store_in_db(evt.timestamp, &evt.kind, &evt.tags); format!("got event {}", new_event.id.unwrap()) } -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok() .content_type("text/html; charset=utf-8") .body(include_str!("../static/form.html")) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(index)) .route("/event", web::post().to(capture_event)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } From cc2a7a0645b2229699518dba2e3cdc4ce5fde733 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:08:25 +0900 Subject: [PATCH 13/23] Update request-handlers --- examples/request-handlers/Cargo.toml | 3 ++- examples/request-handlers/src/handlers_arc.rs | 12 ++++++------ examples/request-handlers/src/main.rs | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/request-handlers/Cargo.toml b/examples/request-handlers/Cargo.toml index 325b659..156950c 100644 --- a/examples/request-handlers/Cargo.toml +++ b/examples/request-handlers/Cargo.toml @@ -4,4 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/request-handlers/src/handlers_arc.rs b/examples/request-handlers/src/handlers_arc.rs index cd9acbe..766dd15 100644 --- a/examples/request-handlers/src/handlers_arc.rs +++ b/examples/request-handlers/src/handlers_arc.rs @@ -8,17 +8,18 @@ struct AppState { count: Arc, } -fn show_count(data: web::Data) -> impl Responder { +async fn show_count(data: web::Data) -> impl Responder { format!("count: {}", data.count.load(Ordering::Relaxed)) } -fn add_one(data: web::Data) -> impl Responder { +async fn add_one(data: web::Data) -> impl Responder { data.count.fetch_add(1, Ordering::Relaxed); format!("count: {}", data.count.load(Ordering::Relaxed)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; let data = AppState { @@ -31,9 +32,8 @@ pub fn main() { .route("/", web::to(show_count)) .route("/add", web::to(add_one)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/request-handlers/src/main.rs b/examples/request-handlers/src/main.rs index 9fb1734..2d29c5f 100644 --- a/examples/request-handlers/src/main.rs +++ b/examples/request-handlers/src/main.rs @@ -8,18 +8,19 @@ struct AppState { count: Cell, } -fn show_count(data: web::Data) -> impl Responder { +async fn show_count(data: web::Data) -> impl Responder { format!("count: {}", data.count.get()) } -fn add_one(data: web::Data) -> impl Responder { +async fn add_one(data: web::Data) -> impl Responder { let count = data.count.get(); data.count.set(count + 1); format!("count: {}", data.count.get()) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; let data = AppState { @@ -32,9 +33,8 @@ fn main() { .route("/", web::to(show_count)) .route("/add", web::to(add_one)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From b0e8a8d51d314a9d461aae8e7aad227764ff685e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:09:52 +0900 Subject: [PATCH 14/23] Update request-routing --- examples/request-routing/Cargo.toml | 3 ++- examples/request-routing/src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/request-routing/Cargo.toml b/examples/request-routing/Cargo.toml index cdef3e6..df5d1d7 100644 --- a/examples/request-routing/Cargo.toml +++ b/examples/request-routing/Cargo.toml @@ -4,4 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/request-routing/src/main.rs b/examples/request-routing/src/main.rs index 8a20019..4e9694a 100644 --- a/examples/request-routing/src/main.rs +++ b/examples/request-routing/src/main.rs @@ -1,23 +1,23 @@ // use actix_web::{web, App, HttpRequest, HttpServer, Responder}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Hello from the index page." } -fn hello(path: web::Path) -> impl Responder { +async fn hello(path: web::Path) -> impl Responder { format!("Hello {}!", &path) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").to(index)) .service(web::resource("/{name}").to(hello)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 4f2f9303493f619c9956a74cd0970c421333df5a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:32:47 +0900 Subject: [PATCH 15/23] Update requests --- content/docs/request.md | 10 +++--- examples/requests/Cargo.toml | 7 ++-- examples/requests/src/main.rs | 10 +++--- examples/requests/src/manual.rs | 51 +++++++++++------------------ examples/requests/src/streaming.rs | 30 ++++++++--------- examples/requests/src/urlencoded.rs | 10 +++--- 6 files changed, 53 insertions(+), 65 deletions(-) diff --git a/content/docs/request.md b/content/docs/request.md index ad71c29..1843bf7 100644 --- a/content/docs/request.md +++ b/content/docs/request.md @@ -78,10 +78,10 @@ In the following example, we read and print the request payload chunk by chunk: {{< include-example example="requests" file="streaming.rs" section="streaming" >}} [examples]: https://github.com/actix/examples/tree/master/json/ -[multipartstruct]: https://docs.rs/actix-multipart/0.1.2/actix_multipart/struct.Multipart.html -[fieldstruct]: https://docs.rs/actix-multipart/0.1.2/actix_multipart/struct.Field.html +[multipartstruct]: https://docs.rs/actix-multipart/0.2/actix_multipart/struct.Multipart.html +[fieldstruct]: https://docs.rs/actix-multipart/0.2/actix_multipart/struct.Field.html [multipartexample]: https://github.com/actix/examples/tree/master/multipart/ -[urlencoded]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.UrlEncoded.html -[payloadextractor]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Payload.html +[urlencoded]: https://docs.rs/actix-web/2/actix_web/dev/struct.UrlEncoded.html +[payloadextractor]: https://docs.rs/actix-web/2/actix_web/web/struct.Payload.html [multipartcrate]: https://crates.io/crates/actix-multipart -[formencoded]:Jhttps://docs.rs/actix-web/1.0.2/actix_web/web/struct.Form.html +[formencoded]:Jhttps://docs.rs/actix-web/2/actix_web/web/struct.Form.html diff --git a/examples/requests/Cargo.toml b/examples/requests/Cargo.toml index 4d26310..3e3a598 100644 --- a/examples/requests/Cargo.toml +++ b/examples/requests/Cargo.toml @@ -6,7 +6,8 @@ edition = "2018" [dependencies] serde = "1.0" serde_json = "1.0" -actix-web = "1.0" -futures = "0.1" +actix-web = "2.0" +actix-rt = "1.0" +futures = "0.3.1" bytes = "0.4" -actix-multipart = "0.1" +actix-multipart = "0.2" diff --git a/examples/requests/src/main.rs b/examples/requests/src/main.rs index 7d822e2..c6a0c1f 100644 --- a/examples/requests/src/main.rs +++ b/examples/requests/src/main.rs @@ -14,15 +14,15 @@ struct Info { } /// extract `Info` using serde -fn index(info: web::Json) -> Result { +async fn index(info: web::Json) -> Result { Ok(format!("Welcome {}!", info.username)) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().route("/", web::post().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/requests/src/manual.rs b/examples/requests/src/manual.rs index 44eeefc..dade24c 100644 --- a/examples/requests/src/manual.rs +++ b/examples/requests/src/manual.rs @@ -1,7 +1,7 @@ // use actix_web::{error, web, App, Error, HttpResponse}; use bytes::BytesMut; -use futures::{Future, Stream}; +use futures::StreamExt; use serde::{Deserialize, Serialize}; use serde_json; @@ -13,41 +13,30 @@ struct MyObj { const MAX_SIZE: usize = 262_144; // max payload size is 256k -pub fn index_manual( - payload: web::Payload, -) -> impl Future { +async fn index_manual(mut payload: web::Payload) -> Result { // payload is a stream of Bytes objects - payload - // `Future::from_err` acts like `?` in that it coerces the error type from - // the future into the final error type - .from_err() - // `fold` will asynchronously read each chunk of the request body and - // call supplied closure, then it resolves to result of closure - .fold(BytesMut::new(), move |mut body, chunk| { - // limit max size of in-memory payload - if (body.len() + chunk.len()) > MAX_SIZE { - Err(error::ErrorBadRequest("overflow")) - } else { - body.extend_from_slice(&chunk); - Ok(body) - } - }) - // `Future::and_then` can be used to merge an asynchronous workflow with a - // synchronous workflow - .and_then(|body| { - // body is loaded, now we can deserialize serde-json - let obj = serde_json::from_slice::(&body)?; - Ok(HttpResponse::Ok().json(obj)) // <- send response - }) + let mut body = BytesMut::new(); + while let Some(chunk) = payload.next().await { + let chunk = chunk?; + // limit max size of in-memory payload + if (body.len() + chunk.len()) > MAX_SIZE { + return Err(error::ErrorBadRequest("overflow")); + } + body.extend_from_slice(&chunk); + } + + // body is loaded, now we can deserialize serde-json + let obj = serde_json::from_slice::(&body)?; + Ok(HttpResponse::Ok().json(obj)) // <- send response } // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::HttpServer; - HttpServer::new(|| App::new().route("/", web::post().to_async(index_manual))) - .bind("127.0.0.1:8088") - .unwrap() + HttpServer::new(|| App::new().route("/", web::post().to(index_manual))) + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } diff --git a/examples/requests/src/streaming.rs b/examples/requests/src/streaming.rs index 9f4ab33..11c74c2 100644 --- a/examples/requests/src/streaming.rs +++ b/examples/requests/src/streaming.rs @@ -1,26 +1,24 @@ // use actix_web::{error, web, Error, HttpResponse}; -use futures::{future::result, Future, Stream}; +use futures::{Future, Stream, StreamExt}; -pub fn index(payload: web::Payload) -> Box> { - Box::new( - payload - .from_err() - .fold((), |_, chunk| { - println!("Chunk: {:?}", chunk); - result::<_, error::PayloadError>(Ok(())) - }) - .map(|_| HttpResponse::Ok().into()), - ) +async fn index(mut body: web::Payload) -> Result { + let mut bytes = web::BytesMut::new(); + while let Some(item) = body.next().await { + bytes.extend_from_slice(&item?); + } + + println!("Chunk: {:?}", bytes); + Ok(HttpResponse::Ok().finish()) } // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; - HttpServer::new(|| App::new().route("/", web::post().to_async(index))) - .bind("127.0.0.1:8088") - .unwrap() + HttpServer::new(|| App::new().route("/", web::post().to(index))) + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } diff --git a/examples/requests/src/urlencoded.rs b/examples/requests/src/urlencoded.rs index 211c5a6..1486308 100644 --- a/examples/requests/src/urlencoded.rs +++ b/examples/requests/src/urlencoded.rs @@ -7,17 +7,17 @@ struct FormData { username: String, } -fn index(form: web::Form) -> HttpResponse { +async fn index(form: web::Form) -> HttpResponse { HttpResponse::Ok().body(format!("username: {}", form.username)) } // -pub fn main() { +#[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") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } From 2cd3428c8ea9a734a5555bb51fa98d5a0022be4e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:47:27 +0900 Subject: [PATCH 16/23] Update responder-trait --- examples/responder-trait/Cargo.toml | 4 +++- examples/responder-trait/src/main.rs | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/responder-trait/Cargo.toml b/examples/responder-trait/Cargo.toml index 565cd46..46bb4bf 100644 --- a/examples/responder-trait/Cargo.toml +++ b/examples/responder-trait/Cargo.toml @@ -4,6 +4,8 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" +futures = "0.3.1" serde = "1.0" serde_json = "1.0" diff --git a/examples/responder-trait/src/main.rs b/examples/responder-trait/src/main.rs index 5b199b3..972e6c2 100644 --- a/examples/responder-trait/src/main.rs +++ b/examples/responder-trait/src/main.rs @@ -1,6 +1,7 @@ // use actix_web::{Error, HttpRequest, HttpResponse, Responder}; use serde::Serialize; +use futures::future::{ready, Ready}; #[derive(Serialize)] struct MyObj { @@ -10,29 +11,29 @@ struct MyObj { // Responder impl Responder for MyObj { type Error = Error; - type Future = Result; + type Future = Ready>; fn respond_to(self, _req: &HttpRequest) -> Self::Future { - let body = serde_json::to_string(&self)?; + let body = serde_json::to_string(&self).unwrap(); // Create response and set content type - Ok(HttpResponse::Ok() + ready(Ok(HttpResponse::Ok() .content_type("application/json") - .body(body)) + .body(body))) } } -fn index() -> impl Responder { +async fn index() -> impl Responder { MyObj { name: "user" } } // -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| App::new().route("/", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } From a255f4aea622e6f09034599c2a942cc20b606bc9 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 02:59:48 +0900 Subject: [PATCH 17/23] Update response --- content/docs/response.md | 4 ++-- examples/responses/Cargo.toml | 5 +++-- examples/responses/src/auto.rs | 10 +++++----- examples/responses/src/brotli.rs | 12 ++++++------ examples/responses/src/brotli_two.rs | 12 ++++++------ examples/responses/src/compress.rs | 10 +++++----- examples/responses/src/identity.rs | 12 ++++++------ examples/responses/src/identity_two.rs | 12 ++++++------ examples/responses/src/json_resp.rs | 10 +++++----- examples/responses/src/main.rs | 10 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/content/docs/response.md b/content/docs/response.md index 79681a1..921dffc 100644 --- a/content/docs/response.md +++ b/content/docs/response.md @@ -82,5 +82,5 @@ is enabled automatically. {{< include-example example="responses" file="chunked.rs" section="chunked" >}} -[responsebuilder]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.HttpResponseBuilder.html -[compressmidddleware]: https://docs.rs/actix-web/1.0.2/actix_web/middleware/struct.Compress.html +[responsebuilder]: https://docs.rs/actix-web/2/actix_web/dev/struct.HttpResponseBuilder.html +[compressmidddleware]: https://docs.rs/actix-web/2/actix_web/middleware/struct.Compress.html diff --git a/examples/responses/Cargo.toml b/examples/responses/Cargo.toml index 8d5624f..ca6de1a 100644 --- a/examples/responses/Cargo.toml +++ b/examples/responses/Cargo.toml @@ -4,7 +4,8 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" serde = "1.0" -futures = "0.1" +futures = "0.3.1" bytes = "0.4" diff --git a/examples/responses/src/auto.rs b/examples/responses/src/auto.rs index 1af1078..a1a1f15 100644 --- a/examples/responses/src/auto.rs +++ b/examples/responses/src/auto.rs @@ -1,11 +1,12 @@ // use actix_web::{http::ContentEncoding, middleware, HttpResponse}; -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok().body("data") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -13,9 +14,8 @@ pub fn main() { .wrap(middleware::Compress::new(ContentEncoding::Br)) .route("/", web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/brotli.rs b/examples/responses/src/brotli.rs index ebdf7e2..2f1cab1 100644 --- a/examples/responses/src/brotli.rs +++ b/examples/responses/src/brotli.rs @@ -1,13 +1,14 @@ // -use actix_web::{http::ContentEncoding, middleware::BodyEncoding, HttpResponse}; +use actix_web::{http::ContentEncoding, dev::BodyEncoding, HttpResponse}; -fn index_br() -> HttpResponse { +async fn index_br() -> HttpResponse { HttpResponse::Ok() .encoding(ContentEncoding::Br) .body("data") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{middleware, web, App, HttpServer}; HttpServer::new(|| { @@ -15,9 +16,8 @@ pub fn main() { .wrap(middleware::Compress::default()) .route("/", web::get().to(index_br)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/brotli_two.rs b/examples/responses/src/brotli_two.rs index cdd79f4..b7325f9 100644 --- a/examples/responses/src/brotli_two.rs +++ b/examples/responses/src/brotli_two.rs @@ -1,11 +1,12 @@ // -use actix_web::{http::ContentEncoding, middleware::BodyEncoding, HttpResponse}; +use actix_web::{http::ContentEncoding, dev::BodyEncoding, HttpResponse}; -fn index_br() -> HttpResponse { +async fn index_br() -> HttpResponse { HttpResponse::Ok().body("data") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{middleware, web, App, HttpServer}; HttpServer::new(|| { @@ -13,9 +14,8 @@ pub fn main() { .wrap(middleware::Compress::new(ContentEncoding::Br)) .route("/", web::get().to(index_br)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/compress.rs b/examples/responses/src/compress.rs index 105b76b..d98799b 100644 --- a/examples/responses/src/compress.rs +++ b/examples/responses/src/compress.rs @@ -1,11 +1,12 @@ // use actix_web::{middleware, HttpResponse}; -fn index_br() -> HttpResponse { +async fn index_br() -> HttpResponse { HttpResponse::Ok().body("data") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -13,9 +14,8 @@ pub fn main() { .wrap(middleware::Compress::default()) .route("/", web::get().to(index_br)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/identity.rs b/examples/responses/src/identity.rs index 2d759d1..0e8980a 100644 --- a/examples/responses/src/identity.rs +++ b/examples/responses/src/identity.rs @@ -1,16 +1,17 @@ // use actix_web::{ - http::ContentEncoding, middleware, middleware::BodyEncoding, HttpResponse, + http::ContentEncoding, middleware, dev::BodyEncoding, HttpResponse, }; -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok() // v- disable compression .encoding(ContentEncoding::Identity) .body("data") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -18,9 +19,8 @@ pub fn main() { .wrap(middleware::Compress::default()) .route("/", web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/identity_two.rs b/examples/responses/src/identity_two.rs index 62839ff..86ff64f 100644 --- a/examples/responses/src/identity_two.rs +++ b/examples/responses/src/identity_two.rs @@ -1,6 +1,6 @@ // use actix_web::{ - http::ContentEncoding, middleware, middleware::BodyEncoding, HttpResponse, + http::ContentEncoding, middleware, dev::BodyEncoding, HttpResponse, }; static HELLO_WORLD: &[u8] = &[ @@ -9,7 +9,7 @@ static HELLO_WORLD: &[u8] = &[ 0x0c, 0x00, 0x00, 0x00, ]; -pub fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok() .encoding(ContentEncoding::Identity) .header("content-encoding", "gzip") @@ -17,7 +17,8 @@ pub fn index() -> HttpResponse { } // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -25,8 +26,7 @@ pub fn main() { .wrap(middleware::Compress::default()) .route("/", web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } diff --git a/examples/responses/src/json_resp.rs b/examples/responses/src/json_resp.rs index 7fc329d..7df6796 100644 --- a/examples/responses/src/json_resp.rs +++ b/examples/responses/src/json_resp.rs @@ -7,19 +7,19 @@ struct MyObj { name: String, } -fn index(obj: web::Path) -> Result { +async fn index(obj: web::Path) -> Result { Ok(HttpResponse::Ok().json(MyObj { name: obj.name.to_string(), })) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; HttpServer::new(|| App::new().route(r"/a/{name}", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/responses/src/main.rs b/examples/responses/src/main.rs index d41f2b7..9ee7a55 100644 --- a/examples/responses/src/main.rs +++ b/examples/responses/src/main.rs @@ -9,7 +9,7 @@ pub mod json_resp; // use actix_web::HttpResponse; -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok() .content_type("plain/text") .header("X-Hdr", "sample") @@ -17,12 +17,12 @@ fn index() -> HttpResponse { } // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| App::new().route("/", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } From e21219c1daf6f042742acfd579b5a29c67f0091d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 03:32:56 +0900 Subject: [PATCH 18/23] Update server --- content/docs/server.md | 18 +++++++++--------- examples/server/Cargo.toml | 8 ++++---- examples/server/src/keep_alive.rs | 5 +++-- examples/server/src/keep_alive_tp.rs | 2 +- examples/server/src/main.rs | 13 +++++-------- examples/server/src/signals.rs | 27 +++++++++------------------ examples/server/src/ssl.rs | 10 +++++----- examples/server/src/workers.rs | 3 ++- 8 files changed, 38 insertions(+), 48 deletions(-) diff --git a/content/docs/server.md b/content/docs/server.md index 8c0c6f0..8a6da09 100644 --- a/content/docs/server.md +++ b/content/docs/server.md @@ -12,7 +12,7 @@ The [**HttpServer**][httpserverstruct] type is responsible for serving http requ must have `Send` + `Sync` boundaries. More about that in the *multi-threading* section. To bind to a specific socket address, [`bind()`][bindmethod] must be used, and it may be -called multiple times. To bind ssl socket, [`bind_ssl()`][bindsslmethod] or +called multiple times. To bind ssl socket, [`bind_openssl()`][bindopensslmethod] or [`bind_rustls()`][bindrusttls] should be used. To start the http server, use one of the start methods. @@ -117,13 +117,13 @@ are available on unix systems. > It is possible to disable signal handling with [`HttpServer::disable_signals()`][disablesignals] method. -[httpserverstruct]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html -[bindmethod]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind -[bindsslmethod]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind_ssl -[bindrusttls]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.bind_rustls -[startmethod]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.start -[workers]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.workers +[httpserverstruct]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html +[bindmethod]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind +[bindopensslmethod]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind_openssl +[bindrusttls]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.bind_rustls +[startmethod]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.start +[workers]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.workers [tlsalpn]: https://tools.ietf.org/html/rfc7301 [exampletls]: https://github.com/actix/examples/tree/master/tls -[shutdowntimeout]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.shutdown_timeout -[disablesignals]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpServer.html#method.disable_signals +[shutdowntimeout]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.shutdown_timeout +[disablesignals]: https://docs.rs/actix-web/2/actix_web/struct.HttpServer.html#method.disable_signals diff --git a/examples/server/Cargo.toml b/examples/server/Cargo.toml index d3bfa22..c620da1 100644 --- a/examples/server/Cargo.toml +++ b/examples/server/Cargo.toml @@ -5,8 +5,8 @@ workspace = "../" edition = "2018" [dependencies] -actix-rt = "0.2" -actix-web = { version = "1.0", features = ["ssl"] } -futures = "0.1" +actix-rt = "1.0" +actix-web = { version = "2.0", features = ["openssl"] } +futures = "0.3.1" openssl = "0.10" -actix-http = "0.2" +actix-http = "1.0" diff --git a/examples/server/src/keep_alive.rs b/examples/server/src/keep_alive.rs index d997286..a59b743 100644 --- a/examples/server/src/keep_alive.rs +++ b/examples/server/src/keep_alive.rs @@ -1,7 +1,8 @@ // use actix_web::{web, App, HttpResponse, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { let one = HttpServer::new(|| { App::new().route("/", web::get().to(|| HttpResponse::Ok())) }) @@ -17,6 +18,6 @@ pub fn main() { }) .keep_alive(None); // <- Disable keep-alive - one.bind("127.0.0.1:8088").unwrap().run().unwrap(); + one.bind("127.0.0.1:8088")?.run().await } // diff --git a/examples/server/src/keep_alive_tp.rs b/examples/server/src/keep_alive_tp.rs index 19287ee..36ea2b3 100644 --- a/examples/server/src/keep_alive_tp.rs +++ b/examples/server/src/keep_alive_tp.rs @@ -1,7 +1,7 @@ // use actix_web::{http, HttpRequest, HttpResponse}; -pub fn index(req: HttpRequest) -> HttpResponse { +async fn index(req: HttpRequest) -> HttpResponse { HttpResponse::Ok() .connection_type(http::ConnectionType::Close) // <- Close connection .force_close() // <- Alternative method diff --git a/examples/server/src/main.rs b/examples/server/src/main.rs index 6d43ee1..aeb8543 100644 --- a/examples/server/src/main.rs +++ b/examples/server/src/main.rs @@ -7,16 +7,13 @@ pub mod workers; //
use actix_web::{web, App, HttpResponse, HttpServer}; -fn main() { - let sys = actix_rt::System::new("example"); - +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().route("/", web::get().to(|| HttpResponse::Ok())) }) - .bind("127.0.0.1:8088") - .unwrap() - .start(); - - let _ = sys.run(); + .bind("127.0.0.1:8088")? + .run() + .await } //
diff --git a/examples/server/src/signals.rs b/examples/server/src/signals.rs index f926622..f623e0d 100644 --- a/examples/server/src/signals.rs +++ b/examples/server/src/signals.rs @@ -1,7 +1,5 @@ -use actix_rt; -use futures::Future; - // +use actix_rt::System; use actix_web::{web, App, HttpResponse, HttpServer}; use std::sync::mpsc; use std::thread; @@ -10,7 +8,7 @@ pub fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { - let sys = actix_rt::System::new("http-server"); + let sys = System::new("http-server"); let addr = HttpServer::new(|| { App::new().route("/", web::get().to(|| HttpResponse::Ok())) @@ -18,24 +16,17 @@ pub fn main() { .bind("127.0.0.1:8088") .unwrap() .shutdown_timeout(60) // <- Set shutdown timeout to 60 seconds - .start(); + .run(); let _ = tx.send(addr); - let _ = sys.run(); }); let addr = rx.recv().unwrap(); - let _ = addr - .pause() - .wait() - .map(|_| println!("`actix_server::ServerCommand::Pause`")); - let _ = addr - .resume() - .wait() - .map(|_| println!("`actix_server::ServerCommand::Resume`")); - let _ = addr - .stop(true) - .wait() - .map(|_| println!("`actix_server::ServerCommand::Stop`")); + let _ = System::new("`actix_server::ServerCommand::Pause`") + .block_on(addr.pause()); + let _ = System::new("`actix_server::ServerCommand::Resume`") + .block_on(addr.resume()); + let _ = System::new("`actix_server::ServerCommand::Stop`") + .block_on(addr.stop(true)); } // diff --git a/examples/server/src/ssl.rs b/examples/server/src/ssl.rs index 4efb8de..a21946a 100644 --- a/examples/server/src/ssl.rs +++ b/examples/server/src/ssl.rs @@ -2,11 +2,12 @@ use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Welcome!" } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { // load ssl keys // to create a self-signed temporary cert for testing: // `openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'` @@ -18,10 +19,9 @@ pub fn main() { builder.set_certificate_chain_file("cert.pem").unwrap(); HttpServer::new(|| App::new().route("/", web::get().to(index))) - .bind_ssl("127.0.0.1:8088", builder) - .unwrap() + .bind_openssl("127.0.0.1:8088", builder)? .run() - .unwrap(); + .await } // // diff --git a/examples/server/src/workers.rs b/examples/server/src/workers.rs index f7eba99..d2b4649 100644 --- a/examples/server/src/workers.rs +++ b/examples/server/src/workers.rs @@ -1,7 +1,8 @@ // use actix_web::{web, App, HttpResponse, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() { HttpServer::new(|| { App::new().route("/", web::get().to(|| HttpResponse::Ok())) }) From 1d6ccff3e8a6dbed5537fc6a9f3f65e0a5030e6c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 03:36:24 +0900 Subject: [PATCH 19/23] Update static-files --- content/docs/static-files.md | 4 ++-- examples/static-files/Cargo.toml | 5 +++-- examples/static-files/src/configuration.rs | 10 +++++----- examples/static-files/src/configuration_two.rs | 8 ++++---- examples/static-files/src/directory.rs | 8 ++++---- examples/static-files/src/main.rs | 10 +++++----- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/content/docs/static-files.md b/content/docs/static-files.md index f3512d5..6f9c09c 100644 --- a/content/docs/static-files.md +++ b/content/docs/static-files.md @@ -44,5 +44,5 @@ The Configuration can also be applied to directory service: {{< include-example example="static-files" file="configuration_two.rs" section="config-two" >}} -[showfileslisting]: https://docs.rs/actix-files/0.1.2/actix_files/struct.Files.html -[indexfile]: https://docs.rs/actix-files/0.1.2/actix_files/struct.Files.html#method.index_file +[showfileslisting]: https://docs.rs/actix-files/0.2/actix_files/struct.Files.html +[indexfile]: https://docs.rs/actix-files/0.2/actix_files/struct.Files.html#method.index_file diff --git a/examples/static-files/Cargo.toml b/examples/static-files/Cargo.toml index 8018328..e37f205 100644 --- a/examples/static-files/Cargo.toml +++ b/examples/static-files/Cargo.toml @@ -4,6 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" -actix-files = "0.1" +actix-web = "2.0" +actix-rt = "1.0" +actix-files = "0.2" mime = "*" diff --git a/examples/static-files/src/configuration.rs b/examples/static-files/src/configuration.rs index 54b5d2a..db663d0 100644 --- a/examples/static-files/src/configuration.rs +++ b/examples/static-files/src/configuration.rs @@ -3,7 +3,7 @@ use actix_files as fs; use actix_web::http::header::{ContentDisposition, DispositionType}; use actix_web::{web, App, Error, HttpRequest, HttpServer}; -fn index(req: HttpRequest) -> Result { +async fn index(req: HttpRequest) -> Result { let path: std::path::PathBuf = req.match_info().query("filename").parse().unwrap(); let file = fs::NamedFile::open(path)?; Ok(file @@ -14,11 +14,11 @@ fn index(req: HttpRequest) -> Result { })) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/static-files/src/configuration_two.rs b/examples/static-files/src/configuration_two.rs index 669e625..11b01b3 100644 --- a/examples/static-files/src/configuration_two.rs +++ b/examples/static-files/src/configuration_two.rs @@ -2,7 +2,8 @@ use actix_files as fs; use actix_web::{App, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().service( fs::Files::new("/static", ".") @@ -10,9 +11,8 @@ pub fn main() { .use_last_modified(true), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/static-files/src/directory.rs b/examples/static-files/src/directory.rs index 6da7ea4..db3131b 100644 --- a/examples/static-files/src/directory.rs +++ b/examples/static-files/src/directory.rs @@ -2,13 +2,13 @@ use actix_files as fs; use actix_web::{App, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().service(fs::Files::new("/static", ".").show_files_listing()) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/static-files/src/main.rs b/examples/static-files/src/main.rs index a30d5db..ae903b0 100644 --- a/examples/static-files/src/main.rs +++ b/examples/static-files/src/main.rs @@ -7,18 +7,18 @@ use actix_files::NamedFile; use actix_web::{HttpRequest, Result}; use std::path::PathBuf; -fn index(req: HttpRequest) -> Result { +async fn index(req: HttpRequest) -> Result { let path: PathBuf = req.match_info().query("filename").parse().unwrap(); Ok(NamedFile::open(path)?) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 7a973d6fe93a52929f9e52fe64591f7e5ff3ae32 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 04:10:02 +0900 Subject: [PATCH 20/23] Update url-dispatch --- content/docs/url-dispatch.md | 38 +++++++++++++-------------- examples/url-dispatch/Cargo.toml | 7 ++--- examples/url-dispatch/src/cfg.rs | 8 +++--- examples/url-dispatch/src/dhandler.rs | 10 +++---- examples/url-dispatch/src/guard.rs | 8 +++--- examples/url-dispatch/src/guard2.rs | 8 +++--- examples/url-dispatch/src/main.rs | 10 +++---- examples/url-dispatch/src/minfo.rs | 10 +++---- examples/url-dispatch/src/norm.rs | 10 +++---- examples/url-dispatch/src/norm2.rs | 8 +++--- examples/url-dispatch/src/path.rs | 10 +++---- examples/url-dispatch/src/path2.rs | 10 +++---- examples/url-dispatch/src/pbuf.rs | 10 +++---- examples/url-dispatch/src/scope.rs | 12 ++++----- examples/url-dispatch/src/url_ext.rs | 10 +++---- examples/url-dispatch/src/urls.rs | 10 +++---- 16 files changed, 90 insertions(+), 89 deletions(-) diff --git a/content/docs/url-dispatch.md b/content/docs/url-dispatch.md index 8a5c873..17edd50 100644 --- a/content/docs/url-dispatch.md +++ b/content/docs/url-dispatch.md @@ -407,24 +407,24 @@ with `App::service()` method. {{< include-example example="url-dispatch" file="dhandler.rs" section="default" >}} [handlersection]: ../handlers/ -[approute]: https://docs.rs/actix-web/1.0.2/actix_web/struct.App.html#method.route -[appservice]: https://docs.rs/actix-web/1.0.2/actix_web/struct.App.html?search=#method.service -[webresource]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Resource.html -[resourcehandler]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Resource.html#method.route -[route]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html -[routeguard]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.guard -[routemethod]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.method -[routeto]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.to -[routetoasync]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.to_async -[matchinfo]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.match_info -[pathget]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.Path.html#method.get -[pathstruct]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.Path.html -[query]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Query.html -[urlfor]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.url_for +[approute]: https://docs.rs/actix-web/2/actix_web/struct.App.html#method.route +[appservice]: https://docs.rs/actix-web/2/actix_web/struct.App.html?search=#method.service +[webresource]: https://docs.rs/actix-web/2/actix_web/struct.Resource.html +[resourcehandler]: https://docs.rs/actix-web/2/actix_web/struct.Resource.html#method.route +[route]: https://docs.rs/actix-web/2/actix_web/struct.Route.html +[routeguard]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.guard +[routemethod]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.method +[routeto]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.to +[routetoasync]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.to_async +[matchinfo]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.match_info +[pathget]: https://docs.rs/actix-web/2/actix_web/dev/struct.Path.html#method.get +[pathstruct]: https://docs.rs/actix-web/2/actix_web/dev/struct.Path.html +[query]: https://docs.rs/actix-web/2/actix_web/web/struct.Query.html +[urlfor]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.url_for [urlobj]: https://docs.rs/url/1.7.2/url/struct.Url.html -[guardtrait]: https://docs.rs/actix-web/1.0.2/actix_web/guard/trait.Guard.html -[guardfuncs]: https://docs.rs/actix-web/1.0.2/actix_web/guard/index.html#functions -[requestextensions]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.extensions -[implfromrequest]: https://docs.rs/actix-web/1.0.2/actix_web/trait.FromRequest.html -[implresponder]: https://docs.rs/actix-web/1.0.2/actix_web/trait.Responder.html +[guardtrait]: https://docs.rs/actix-web/2/actix_web/guard/trait.Guard.html +[guardfuncs]: https://docs.rs/actix-web/2/actix_web/guard/index.html#functions +[requestextensions]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.extensions +[implfromrequest]: https://docs.rs/actix-web/2/actix_web/trait.FromRequest.html +[implresponder]: https://docs.rs/actix-web/2/actix_web/trait.Responder.html [pathextractor]: ../extractors diff --git a/examples/url-dispatch/Cargo.toml b/examples/url-dispatch/Cargo.toml index b7914ca..dbd9149 100644 --- a/examples/url-dispatch/Cargo.toml +++ b/examples/url-dispatch/Cargo.toml @@ -5,8 +5,9 @@ edition = "2018" workspace = "../" [dependencies] -actix = "0.8" -actix-web = "1.0" -futures = "0.1" +actix = "0.9" +actix-rt = "1.0" +actix-web = "2.0" +futures = "0.3.1" openssl = "0.10" serde = "1.0" diff --git a/examples/url-dispatch/src/cfg.rs b/examples/url-dispatch/src/cfg.rs index dfad2cd..21381bd 100644 --- a/examples/url-dispatch/src/cfg.rs +++ b/examples/url-dispatch/src/cfg.rs @@ -1,7 +1,8 @@ use actix_web::{guard, web, App, HttpResponse}; #[rustfmt::skip] -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::HttpServer; HttpServer::new(|| { @@ -16,8 +17,7 @@ App::new().service( ) // }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } diff --git a/examples/url-dispatch/src/dhandler.rs b/examples/url-dispatch/src/dhandler.rs index e67891a..dad5c07 100644 --- a/examples/url-dispatch/src/dhandler.rs +++ b/examples/url-dispatch/src/dhandler.rs @@ -1,11 +1,12 @@ use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Welcome!" } // -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").route(web::get().to(index))) @@ -15,9 +16,8 @@ pub fn main() { .to(|| HttpResponse::MethodNotAllowed()), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/guard.rs b/examples/url-dispatch/src/guard.rs index 1ef5d6b..48eddbf 100644 --- a/examples/url-dispatch/src/guard.rs +++ b/examples/url-dispatch/src/guard.rs @@ -9,7 +9,8 @@ impl Guard for ContentTypeHeader { } } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -20,9 +21,8 @@ pub fn main() { .to(|| HttpResponse::Ok()), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/guard2.rs b/examples/url-dispatch/src/guard2.rs index 2d3d30b..bef0407 100644 --- a/examples/url-dispatch/src/guard2.rs +++ b/examples/url-dispatch/src/guard2.rs @@ -1,7 +1,8 @@ // use actix_web::{guard, web, App, HttpResponse, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().route( "/", @@ -10,9 +11,8 @@ pub fn main() { .to(|| HttpResponse::MethodNotAllowed()), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/main.rs b/examples/url-dispatch/src/main.rs index 009b26a..85b61e7 100644 --- a/examples/url-dispatch/src/main.rs +++ b/examples/url-dispatch/src/main.rs @@ -16,19 +16,19 @@ pub mod urls; //
use actix_web::{web, App, HttpResponse, HttpServer}; -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok().body("Hello") } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(index)) .route("/user", web::post().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //
diff --git a/examples/url-dispatch/src/minfo.rs b/examples/url-dispatch/src/minfo.rs index 7c993d7..16dc037 100644 --- a/examples/url-dispatch/src/minfo.rs +++ b/examples/url-dispatch/src/minfo.rs @@ -1,14 +1,15 @@ // use actix_web::{HttpRequest, HttpResponse, Result}; -fn index(req: HttpRequest) -> Result { +async fn index(req: HttpRequest) -> Result { let v1: u8 = req.match_info().get("v1").unwrap().parse().unwrap(); let v2: u8 = req.match_info().query("v2").parse().unwrap(); let (v3, v4): (u8, u8) = req.match_info().load().unwrap(); Ok(format!("Values {} {} {} {}", v1, v2, v3, v4)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -16,9 +17,8 @@ pub fn main() { .route("/a/{v1}/{v2}/", web::get().to(index)) .route("", web::get().to(|| HttpResponse::Ok())) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/norm.rs b/examples/url-dispatch/src/norm.rs index 4d1abf7..12c27aa 100644 --- a/examples/url-dispatch/src/norm.rs +++ b/examples/url-dispatch/src/norm.rs @@ -1,11 +1,12 @@ // use actix_web::{middleware, HttpResponse}; -fn index() -> HttpResponse { +async fn index() -> HttpResponse { HttpResponse::Ok().body("Hello") } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -13,9 +14,8 @@ pub fn main() { .wrap(middleware::NormalizePath) .route("/resource/", web::to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/norm2.rs b/examples/url-dispatch/src/norm2.rs index a704fa7..c4cc7d5 100644 --- a/examples/url-dispatch/src/norm2.rs +++ b/examples/url-dispatch/src/norm2.rs @@ -7,16 +7,16 @@ fn index() -> HttpResponse { // use actix_web::{http::Method, middleware, web, App, HttpServer}; -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .wrap(middleware::NormalizePath) .route("/resource/", web::get().to(index)) .default_service(web::route().method(Method::GET)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/path.rs b/examples/url-dispatch/src/path.rs index 11e2a99..81a6359 100644 --- a/examples/url-dispatch/src/path.rs +++ b/examples/url-dispatch/src/path.rs @@ -1,11 +1,12 @@ // use actix_web::{web, Result}; -fn index(info: web::Path<(String, u32)>) -> Result { +async fn index(info: web::Path<(String, u32)>) -> Result { Ok(format!("Welcome {}! id: {}", info.0, info.1)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; HttpServer::new(|| { @@ -14,9 +15,8 @@ pub fn main() { web::get().to(index), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/path2.rs b/examples/url-dispatch/src/path2.rs index 799a412..7cd60a4 100644 --- a/examples/url-dispatch/src/path2.rs +++ b/examples/url-dispatch/src/path2.rs @@ -8,11 +8,12 @@ struct Info { } // extract path info using serde -fn index(info: web::Path) -> Result { +async fn index(info: web::Path) -> Result { Ok(format!("Welcome {}!", info.username)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; HttpServer::new(|| { @@ -21,9 +22,8 @@ pub fn main() { web::get().to(index), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/pbuf.rs b/examples/url-dispatch/src/pbuf.rs index 36b7e7c..5b037bd 100644 --- a/examples/url-dispatch/src/pbuf.rs +++ b/examples/url-dispatch/src/pbuf.rs @@ -2,18 +2,18 @@ use actix_web::{HttpRequest, Result}; use std::path::PathBuf; -fn index(req: HttpRequest) -> Result { +async fn index(req: HttpRequest) -> Result { let path: PathBuf = req.match_info().query("tail").parse().unwrap(); Ok(format!("Path {:?}", path)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| App::new().route(r"/a/{tail:.*}", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/scope.rs b/examples/url-dispatch/src/scope.rs index 11ac91e..ba4677e 100644 --- a/examples/url-dispatch/src/scope.rs +++ b/examples/url-dispatch/src/scope.rs @@ -1,15 +1,16 @@ use actix_web::{web, App, HttpResponse, HttpServer}; // -fn show_users() -> HttpResponse { +async fn show_users() -> HttpResponse { HttpResponse::Ok().body("Show users") } -fn user_detail(path: web::Path<(u32,)>) -> HttpResponse { +async fn user_detail(path: web::Path<(u32,)>) -> HttpResponse { HttpResponse::Ok().body(format!("User detail: {}", path.0)) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().service( web::scope("/users") @@ -17,9 +18,8 @@ pub fn main() { .route("/show/{id}", web::get().to(user_detail)), ) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/url_ext.rs b/examples/url-dispatch/src/url_ext.rs index 7de8e6e..0d9ec9a 100644 --- a/examples/url-dispatch/src/url_ext.rs +++ b/examples/url-dispatch/src/url_ext.rs @@ -1,14 +1,15 @@ // use actix_web::{HttpRequest, Responder}; -fn index(req: HttpRequest) -> impl Responder { +async fn index(req: HttpRequest) -> impl Responder { let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap(); assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0"); url.into_string() } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -17,9 +18,8 @@ pub fn main() { .external_resource("youtube", "https://youtube.com/watch/{video_id}") .route("/", actix_web::web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // diff --git a/examples/url-dispatch/src/urls.rs b/examples/url-dispatch/src/urls.rs index 8fc03fb..66ec903 100644 --- a/examples/url-dispatch/src/urls.rs +++ b/examples/url-dispatch/src/urls.rs @@ -1,7 +1,7 @@ // use actix_web::{guard, http::header, HttpRequest, HttpResponse, Result}; -fn index(req: HttpRequest) -> Result { +async fn index(req: HttpRequest) -> Result { let url = req.url_for("foo", &["1", "2", "3"])?; // <- generate url for "foo" resource Ok(HttpResponse::Found() @@ -9,7 +9,8 @@ fn index(req: HttpRequest) -> Result { .finish()) } -pub fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { use actix_web::{web, App, HttpServer}; HttpServer::new(|| { @@ -22,9 +23,8 @@ pub fn main() { ) .route("/test/", web::get().to(index)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 9f385d384b72e87dbb72ddf474c8596fe856b49e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 04:16:54 +0900 Subject: [PATCH 21/23] Update websockets --- content/docs/websockets.md | 4 ++-- examples/websockets/Cargo.toml | 7 ++++--- examples/websockets/src/main.rs | 24 ++++++++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/content/docs/websockets.md b/content/docs/websockets.md index d7e0f20..4e200cf 100644 --- a/content/docs/websockets.md +++ b/content/docs/websockets.md @@ -18,7 +18,7 @@ The following is an example of a simple websocket echo server: > An example chat server with the ability to chat over a websocket or tcp connection > is available in [websocket-chat directory][chat] -[message]: https://docs.rs/actix-web-actors/1.0.0/actix_web_actors/ws/enum.Message.html -[payload]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Payload.html +[message]: https://docs.rs/actix-web-actors/2/actix_web_actors/ws/enum.Message.html +[payload]: https://docs.rs/actix-web/2/actix_web/web/struct.Payload.html [examples]: https://github.com/actix/examples/tree/master/websocket/ [chat]: https://github.com/actix/examples/tree/master/websocket-chat/ diff --git a/examples/websockets/Cargo.toml b/examples/websockets/Cargo.toml index e8f5b50..1f58706 100644 --- a/examples/websockets/Cargo.toml +++ b/examples/websockets/Cargo.toml @@ -4,6 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -actix = "0.8" -actix-web = "1.0" -actix-web-actors = "1.0" +actix = "0.9" +actix-rt = "1.0" +actix-web = "2.0" +actix-web-actors = "2.0" diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs index fd49c5c..8198d34 100644 --- a/examples/websockets/src/main.rs +++ b/examples/websockets/src/main.rs @@ -11,29 +11,33 @@ impl Actor for MyWs { } /// Handler for ws::Message message -impl StreamHandler for MyWs { - fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) { +impl StreamHandler> for MyWs { + fn handle( + &mut self, + msg: Result, + ctx: &mut Self::Context, + ) { match msg { - ws::Message::Ping(msg) => ctx.pong(&msg), - ws::Message::Text(text) => ctx.text(text), - ws::Message::Binary(bin) => ctx.binary(bin), + Ok(ws::Message::Ping(msg)) => ctx.pong(&msg), + Ok(ws::Message::Text(text)) => ctx.text(text), + Ok(ws::Message::Binary(bin)) => ctx.binary(bin), _ => (), } } } -fn index(req: HttpRequest, stream: web::Payload) -> Result { +async fn index(req: HttpRequest, stream: web::Payload) -> Result { let resp = ws::start(MyWs {}, &req, stream); println!("{:?}", resp); resp } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| App::new().route("/ws/", web::get().to(index))) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } // From 016fdd067c86d1834c1f41b5566bec1693c4573e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 04:18:24 +0900 Subject: [PATCH 22/23] Bump up actix(-web) version and MSRV --- config.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.toml b/config.toml index ed26be7..63e12d8 100644 --- a/config.toml +++ b/config.toml @@ -15,7 +15,7 @@ baseURL = "https://actix.rs" weight = 1 [params] -actixVersion = "0.7" -actixWebVersion = "1.0" -actixWebMinRustVersion = "1.36" +actixVersion = "0.9" +actixWebVersion = "2.0" +actixWebMinRustVersion = "1.39" actixMinRustVersion = "1.31" From 9df2e8d85d9c3fc8b2b7830153cf03ccbe2280fe Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 16:21:11 +0900 Subject: [PATCH 23/23] Fix Actix MSRV --- config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.toml b/config.toml index 63e12d8..72274c9 100644 --- a/config.toml +++ b/config.toml @@ -18,4 +18,4 @@ baseURL = "https://actix.rs" actixVersion = "0.9" actixWebVersion = "2.0" actixWebMinRustVersion = "1.39" -actixMinRustVersion = "1.31" +actixMinRustVersion = "1.39"