Skip to content

Commit

Permalink
chore: upgrade to ntex 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s committed May 28, 2024
1 parent 7034dcc commit 10e4a2b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ntex-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ name = "ntex_cors"
path = "src/lib.rs"

[dependencies]
ntex = "1.1"
ntex = "2"
derive_more = "0.99"
futures = "0.3"

[dev-dependencies]
ntex = { version = "1.1", features=["tokio"] }
ntex = { version = "2", features=["tokio"] }
4 changes: 2 additions & 2 deletions ntex-cors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ where
type Response = WebResponse;
type Error = S::Error;

ntex::forward_poll_ready!(service);
ntex::forward_poll_shutdown!(service);
ntex::forward_ready!(service);
ntex::forward_shutdown!(service);

async fn call(
&self,
Expand Down
4 changes: 2 additions & 2 deletions ntex-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name = "ntex_files"
path = "src/lib.rs"

[dependencies]
ntex = "1.1"
ntex = "2"
ntex-http = "0.1.12"
bitflags = "2.1"
futures = "0.3"
Expand All @@ -34,4 +34,4 @@ language-tags = "0.3"
httpdate = "1.0"

[dev-dependencies]
ntex = { version = "1.1", features = ["tokio", "openssl", "compress"] }
ntex = { version = "2", features = ["tokio", "openssl", "compress"] }
9 changes: 2 additions & 7 deletions ntex-files/src/file_header/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ use self::Method::{Connect, Delete, Extension, Get, Head, Options, Patch, Post,
///
/// It may make sense to grow this to include all variants currently
/// registered with IANA, if they are at all common to use.
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Default, Clone, PartialEq, Eq, Hash, Debug)]
pub enum Method {
/// OPTIONS
Options,
/// GET
#[default]
Get,
/// POST
Post,
Expand Down Expand Up @@ -141,12 +142,6 @@ impl fmt::Display for Method {
}
}

impl Default for Method {
fn default() -> Method {
Method::Get
}
}

impl From<http::Method> for Method {
fn from(method: http::Method) -> Method {
match method {
Expand Down
4 changes: 2 additions & 2 deletions ntex-identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ default = ["cookie-policy"]
cookie-policy = ["cookie/secure", "ntex/cookie"]

[dependencies]
ntex = "1.1"
ntex = "2"
futures = "0.3"
serde = "1.0"
serde_json = "1.0"
Expand All @@ -30,4 +30,4 @@ cookie = { version = "0.18", features = ["private"] }
time = { version = "0.3", default-features = false, features = ["std"] }

[dev-dependencies]
ntex = { version = "1.1", features=["tokio"] }
ntex = { version = "2", features=["tokio"] }
12 changes: 6 additions & 6 deletions ntex-identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ where
type Response = WebResponse;
type Error = S::Error;

ntex::forward_poll_ready!(service);
ntex::forward_poll_shutdown!(service);
ntex::forward_ready!(service);
ntex::forward_shutdown!(service);

async fn call(
&self,
Expand Down Expand Up @@ -571,7 +571,7 @@ mod tests {
use super::*;
use ntex::web::test::{self, TestRequest};
use ntex::web::{self, error, App, Error, HttpResponse};
use ntex::{http::StatusCode, service::into_service, service::Pipeline, time};
use ntex::{http::StatusCode, service::fn_service, service::Pipeline, time};

const COOKIE_KEY_MASTER: [u8; 32] = [0; 32];
const COOKIE_NAME: &str = "ntex_auth";
Expand Down Expand Up @@ -973,7 +973,7 @@ mod tests {

#[ntex::test]
async fn test_borrowed_mut_error() {
use futures::future::{lazy, ok, Ready};
use futures::future::{ok, Ready};
use ntex::web::{DefaultError, Error};

struct Ident;
Expand All @@ -998,7 +998,7 @@ mod tests {

let srv: Pipeline<_> = IdentityServiceMiddleware {
backend: Rc::new(Ident),
service: into_service(|_: WebRequest<DefaultError>| async move {
service: fn_service(|_: WebRequest<DefaultError>| async move {
time::sleep(time::Seconds(100)).await;
Err::<WebResponse, _>(error::ErrorBadRequest("error"))
}),
Expand All @@ -1012,6 +1012,6 @@ mod tests {
});
time::sleep(time::Millis(50)).await;

let _ = lazy(|cx| srv.poll_ready(cx)).await;
srv.ready().await.expect("srv to be ready");
}
}
4 changes: 2 additions & 2 deletions ntex-multipart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name = "ntex_multipart"
path = "src/lib.rs"

[dependencies]
ntex = "1.1"
ntex = "2"
derive_more = "0.99"
httparse = "1.3"
futures = "0.3"
Expand All @@ -25,4 +25,4 @@ mime = "0.3"
twoway = "0.2"

[dev-dependencies]
ntex = { version = "1.1", features=["tokio"] }
ntex = { version = "2", features=["tokio"] }
4 changes: 2 additions & 2 deletions ntex-session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ default = ["cookie-session"]
cookie-session = ["cookie/secure", "ntex/cookie"]

[dependencies]
ntex = "1.1"
ntex = "2"
cookie = "0.18"
derive_more = "0.99"
futures = "0.3"
Expand All @@ -31,4 +31,4 @@ serde_json = "1.0"
time = { version = "0.3", default-features = false, features = ["std"] }

[dev-dependencies]
ntex = { version = "1.1", features=["tokio"] }
ntex = { version = "2", features=["tokio"] }
4 changes: 2 additions & 2 deletions ntex-session/src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ where
type Response = WebResponse;
type Error = S::Error;

ntex::forward_poll_ready!(service);
ntex::forward_poll_shutdown!(service);
ntex::forward_ready!(service);
ntex::forward_shutdown!(service);

/// On first request, a new session cookie is returned in response, regardless
/// of whether any session state is set. With subsequent requests, if the
Expand Down

0 comments on commit 10e4a2b

Please sign in to comment.