From 84c2676b72b39ccec0735a1ebbfe2a7f49699e82 Mon Sep 17 00:00:00 2001 From: leone Date: Fri, 12 Jan 2024 11:36:23 +0100 Subject: [PATCH] chore: upgrade to ntex 1.0 (#3) * chore: upgrade to ntex 1.0 --- .github/workflows/rust.yml | 3 +-- examples/application/Cargo.toml | 2 +- examples/async-handlers/Cargo.toml | 2 +- examples/databases/Cargo.toml | 2 +- examples/either/Cargo.toml | 2 +- examples/errors/Cargo.toml | 2 +- examples/extractors/Cargo.toml | 2 +- examples/flexible-responders/Cargo.toml | 2 +- examples/getting-started/Cargo.toml | 2 +- examples/http2/Cargo.toml | 2 +- examples/main-example/Cargo.toml | 2 +- examples/middleware/Cargo.toml | 4 ++-- examples/middleware/src/errorhandler.rs | 6 +----- examples/middleware/src/main.rs | 15 ++++----------- examples/powerful-extractors/Cargo.toml | 2 +- examples/request-handlers/Cargo.toml | 2 +- examples/request-routing/Cargo.toml | 2 +- examples/requests/Cargo.toml | 4 ++-- examples/responses/Cargo.toml | 2 +- examples/server/Cargo.toml | 2 +- examples/static-files/Cargo.toml | 4 ++-- examples/testing/Cargo.toml | 2 +- examples/url-dispatch/Cargo.toml | 2 +- examples/websockets/Cargo.toml | 2 +- package.json | 2 +- vars.js | 4 ++-- 26 files changed, 33 insertions(+), 45 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3328db0..776cdd4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,8 +16,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions-rust-lang/setup-rust-toolchain@v1.3.5 - + - uses: actions-rust-lang/setup-rust-toolchain@v1.6 - name: test examples run: | cd examples diff --git a/examples/application/Cargo.toml b/examples/application/Cargo.toml index b3ec0d6..ac2fab5 100644 --- a/examples/application/Cargo.toml +++ b/examples/application/Cargo.toml @@ -5,4 +5,4 @@ edition = "2018" workspace = "../" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/async-handlers/Cargo.toml b/examples/async-handlers/Cargo.toml index 800c163..ff5f3f0 100644 --- a/examples/async-handlers/Cargo.toml +++ b/examples/async-handlers/Cargo.toml @@ -4,6 +4,6 @@ version = "2.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } futures = "0.3.1" bytes = "0.5" diff --git a/examples/databases/Cargo.toml b/examples/databases/Cargo.toml index c8fd166..984c6b0 100644 --- a/examples/databases/Cargo.toml +++ b/examples/databases/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diesel = { version = "2", features = ["sqlite", "r2d2"] } serde = { version = "1", features = ["derive"] } uuid = { version = "1", features = ["v4"] } diff --git a/examples/either/Cargo.toml b/examples/either/Cargo.toml index 5a761ae..8d9e10a 100644 --- a/examples/either/Cargo.toml +++ b/examples/either/Cargo.toml @@ -4,4 +4,4 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/errors/Cargo.toml b/examples/errors/Cargo.toml index dc88f58..9344fab 100644 --- a/examples/errors/Cargo.toml +++ b/examples/errors/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } derive_more = "0.99" env_logger = "0.7" log = "0.4" diff --git a/examples/extractors/Cargo.toml b/examples/extractors/Cargo.toml index 3c10bf8..1b50ca5 100644 --- a/examples/extractors/Cargo.toml +++ b/examples/extractors/Cargo.toml @@ -4,6 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } serde = "1.0" serde_json = "1.0" diff --git a/examples/flexible-responders/Cargo.toml b/examples/flexible-responders/Cargo.toml index aa01748..19647c3 100644 --- a/examples/flexible-responders/Cargo.toml +++ b/examples/flexible-responders/Cargo.toml @@ -4,5 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } serde = "1.0" diff --git a/examples/getting-started/Cargo.toml b/examples/getting-started/Cargo.toml index 8ef6b63..f8a9fbd 100644 --- a/examples/getting-started/Cargo.toml +++ b/examples/getting-started/Cargo.toml @@ -5,4 +5,4 @@ edition = "2018" workspace = "../" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/http2/Cargo.toml b/examples/http2/Cargo.toml index e4ccc42..5261d2f 100644 --- a/examples/http2/Cargo.toml +++ b/examples/http2/Cargo.toml @@ -4,5 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio", "openssl"] } +ntex = { version = "1.0.0", features = ["tokio", "openssl"] } openssl = { version = "0.10", features = ["v110", "vendored"] } diff --git a/examples/main-example/Cargo.toml b/examples/main-example/Cargo.toml index 0b4b17c..9687843 100644 --- a/examples/main-example/Cargo.toml +++ b/examples/main-example/Cargo.toml @@ -4,4 +4,4 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/middleware/Cargo.toml b/examples/middleware/Cargo.toml index 9c2075e..570d7ad 100644 --- a/examples/middleware/Cargo.toml +++ b/examples/middleware/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio", "cookie"] } -ntex-session = { version = "0.3.0" } +ntex = { version = "1.0.0", features = ["tokio", "cookie"] } +ntex-session = { version = "0.4.0" } futures-util = { version = "0.3.7", default-features = false, features = ["std"] } env_logger = "0.10.0" diff --git a/examples/middleware/src/errorhandler.rs b/examples/middleware/src/errorhandler.rs index 89bd25d..d9df50a 100644 --- a/examples/middleware/src/errorhandler.rs +++ b/examples/middleware/src/errorhandler.rs @@ -3,7 +3,6 @@ // use ntex::http::header; use ntex::service::{Middleware, Service, ServiceCtx}; -use ntex::util::BoxFuture; use ntex::web; pub struct Error; @@ -27,12 +26,10 @@ where { type Response = web::WebResponse; type Error = web::Error; - type Future<'f> = BoxFuture<'f, Result> where Self: 'f; ntex::forward_poll_ready!(service); - fn call<'a>(&'a self, req: web::WebRequest, ctx: ServiceCtx<'a, Self>) -> Self::Future<'_> { - Box::pin(async move { + async fn call(&self, req: web::WebRequest, ctx: ServiceCtx<'_, Self>) -> Result { ctx.call(&self.service, req).await.map(|mut res| { let status = res.status(); if status.is_client_error() || status.is_server_error() { @@ -43,7 +40,6 @@ where } res }) - }) } } diff --git a/examples/middleware/src/main.rs b/examples/middleware/src/main.rs index e32f5fc..6ddd769 100644 --- a/examples/middleware/src/main.rs +++ b/examples/middleware/src/main.rs @@ -5,7 +5,6 @@ pub mod user_sessions; // use ntex::service::{Middleware, Service, ServiceCtx}; -use ntex::util::BoxFuture; use ntex::web; // There are two steps in middleware processing. @@ -33,20 +32,14 @@ where { type Response = web::WebResponse; type Error = web::Error; - type Future<'f> = BoxFuture<'f, Result> where Self: 'f; ntex::forward_poll_ready!(service); - fn call<'a>(&'a self, req: web::WebRequest, ctx: ServiceCtx<'a, Self>) -> Self::Future<'_> { + async fn call(&self, req: web::WebRequest, ctx: ServiceCtx<'_, Self>) -> Result { println!("Hi from start. You requested: {}", req.path()); - - let fut = ctx.call(&self.service, req); - Box::pin(async move { - let res = fut.await?; - - println!("Hi from response"); - Ok(res) - }) + let res = ctx.call(&self.service, req).await?; + println!("Hi from response"); + Ok(res) } } // diff --git a/examples/powerful-extractors/Cargo.toml b/examples/powerful-extractors/Cargo.toml index f045e8c..cb675d8 100644 --- a/examples/powerful-extractors/Cargo.toml +++ b/examples/powerful-extractors/Cargo.toml @@ -4,5 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } serde = "1.0" diff --git a/examples/request-handlers/Cargo.toml b/examples/request-handlers/Cargo.toml index b2080d0..82dd103 100644 --- a/examples/request-handlers/Cargo.toml +++ b/examples/request-handlers/Cargo.toml @@ -4,4 +4,4 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/request-routing/Cargo.toml b/examples/request-routing/Cargo.toml index 12e7d16..f3b253c 100644 --- a/examples/request-routing/Cargo.toml +++ b/examples/request-routing/Cargo.toml @@ -4,4 +4,4 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/examples/requests/Cargo.toml b/examples/requests/Cargo.toml index 8d0fcc9..b3b7073 100644 --- a/examples/requests/Cargo.toml +++ b/examples/requests/Cargo.toml @@ -6,6 +6,6 @@ edition = "2018" [dependencies] serde = "1.0" serde_json = "1.0" -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } futures = "0.3.1" -ntex-multipart = "0.3.0" +ntex-multipart = "0.4.0" diff --git a/examples/responses/Cargo.toml b/examples/responses/Cargo.toml index 642509f..57306dd 100644 --- a/examples/responses/Cargo.toml +++ b/examples/responses/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio", "compress"] } +ntex = { version = "1.0.0", features = ["tokio", "compress"] } serde = "1.0" futures = "0.3.1" bytes = "0.5" diff --git a/examples/server/Cargo.toml b/examples/server/Cargo.toml index 4cdc35f..1c7cdc7 100644 --- a/examples/server/Cargo.toml +++ b/examples/server/Cargo.toml @@ -5,7 +5,7 @@ workspace = "../" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio", "openssl"] } +ntex = { version = "1.0.0", features = ["tokio", "openssl"] } futures = "0.3" openssl = { version = "0.10", features = ["vendored"] } tokio = { version = "1.16.1", features = ["full"] } diff --git a/examples/static-files/Cargo.toml b/examples/static-files/Cargo.toml index e74c30a..dc0c1cf 100644 --- a/examples/static-files/Cargo.toml +++ b/examples/static-files/Cargo.toml @@ -4,6 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } -ntex-files = "0.3.0" +ntex = { version = "1.0.0", features = ["tokio"] } +ntex-files = "0.4.0" mime = "0.3" diff --git a/examples/testing/Cargo.toml b/examples/testing/Cargo.toml index e6f3d9b..4c8498d 100644 --- a/examples/testing/Cargo.toml +++ b/examples/testing/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2018" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } futures = "0.3" futures-util = "0.3" bytes = "0.5" diff --git a/examples/url-dispatch/Cargo.toml b/examples/url-dispatch/Cargo.toml index 5805645..c3a8240 100644 --- a/examples/url-dispatch/Cargo.toml +++ b/examples/url-dispatch/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" workspace = "../" [dependencies] -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } futures = "0.3.1" openssl = "0.10" serde = "1.0" diff --git a/examples/websockets/Cargo.toml b/examples/websockets/Cargo.toml index 32f9c13..0ac3129 100644 --- a/examples/websockets/Cargo.toml +++ b/examples/websockets/Cargo.toml @@ -5,4 +5,4 @@ edition = "2018" [dependencies] futures = "0.3.27" -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0.0", features = ["tokio"] } diff --git a/package.json b/package.json index 741d8eb..4ade722 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ntex-website", - "version": "1.0.1", + "version": "1.1.0", "private": true, "scripts": { "docusaurus": "docusaurus", diff --git a/vars.js b/vars.js index 05a4555..1d962cf 100644 --- a/vars.js +++ b/vars.js @@ -1,4 +1,4 @@ module.exports = { - rustVersion: '1.66', - ntexMajorVersion: '0.7', + rustVersion: '1.75', + ntexMajorVersion: '1.0', };