Skip to content

Commit

Permalink
standardize future types to ones from actix_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Dec 8, 2021
1 parent ec66754 commit 5605178
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 42 deletions.
5 changes: 3 additions & 2 deletions actix-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ name = "actix_cors"
path = "src/lib.rs"

[dependencies]
actix-web = { version = "4.0.0-beta.10", default-features = false }
actix-service = "2.0.0"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.10", default-features = false }

derive_more = "0.99.5"
futures-util = { version = "0.3.7", default-features = false }
Expand All @@ -28,5 +29,5 @@ smallvec = "1.6"

[dev-dependencies]
actix-rt = "2"
pretty_env_logger = "0.4"
env_logger = "0.9"
regex = "1.4"
2 changes: 1 addition & 1 deletion actix-cors/examples/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use actix_web::{http::header, web, App, HttpServer};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
pretty_env_logger::init();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));

HttpServer::new(move || {
App::new()
Expand Down
2 changes: 1 addition & 1 deletion actix-cors/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use std::{
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
};

use actix_utils::future::{self, Ready};
use actix_web::{
body::MessageBody,
dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
error::{Error, Result},
http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
Either,
};
use futures_util::future::{self, Ready};
use log::error;
use once_cell::sync::Lazy;
use smallvec::smallvec;
Expand Down
9 changes: 5 additions & 4 deletions actix-cors/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};

use actix_utils::future::{ok, Either, Ready};
use actix_web::{
body::{AnyBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse},
Expand All @@ -10,7 +11,7 @@ use actix_web::{
},
HttpResponse,
};
use futures_util::future::{ok, Either, FutureExt as _, LocalBoxFuture, Ready, TryFutureExt as _};
use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
use log::debug;

use crate::{builder::intersperse_header_values, AllOrSome, Inner};
Expand Down Expand Up @@ -155,15 +156,15 @@ where
if self.inner.preflight && req.method() == Method::OPTIONS {
let inner = Rc::clone(&self.inner);
let res = Self::handle_preflight(&inner, req);
Either::Left(ok(res))
Either::left(ok(res))
} else {
let origin = req.headers().get(header::ORIGIN).cloned();

if origin.is_some() {
// Only check requests with a origin header.
if let Err(err) = self.inner.validate_origin(req.head()) {
debug!("origin validation failed; inner service is not called");
return Either::Left(ok(req.error_response(err)));
return Either::left(ok(req.error_response(err)));
}
}

Expand All @@ -183,7 +184,7 @@ where
.map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
.boxed_local();

Either::Right(res)
Either::right(res)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion actix-cors/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use actix_service::fn_service;
use actix_utils::future::ok;
use actix_web::{
dev::{ServiceRequest, Transform},
http::{header, HeaderValue, Method, StatusCode},
test::{self, TestRequest},
HttpResponse,
};
use futures_util::future::ok;
use regex::bytes::Regex;

use actix_cors::Cors;
Expand Down
3 changes: 2 additions & 1 deletion actix-identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Nikolay Kim <[email protected]>"]
description = "Identity service for Actix web"
keywords = ["actix", "auth", "identity", "web", "security"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras"
repository = "https://github.com/actix/actix-extras.git"
license = "MIT OR Apache-2.0"
edition = "2018"

Expand All @@ -15,6 +15,7 @@ path = "src/lib.rs"

[dependencies]
actix-service = "2.0.0"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.10", default-features = false, features = ["cookies", "secure-cookies"] }
futures-util = { version = "0.3.7", default-features = false }
serde = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion actix-identity/src/cookie.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{rc::Rc, time::SystemTime};

use futures_util::future::{ready, Ready};
use actix_utils::future::{ready, Ready};
use serde::{Deserialize, Serialize};
use time::Duration;

Expand Down
2 changes: 1 addition & 1 deletion actix-identity/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use actix_web::{
dev::{Extensions, Payload},
Error, FromRequest, HttpRequest,
};
use futures_util::future::{ready, Ready};
use actix_utils::future::{ready, Ready};

pub(crate) struct IdentityItem {
pub(crate) id: Option<String>,
Expand Down
6 changes: 4 additions & 2 deletions actix-identity/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::{error::Error as StdError, rc::Rc};

use actix_utils::future::{ready, Ready};
use actix_web::{
body::{AnyBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error, HttpMessage, Result,
};
use futures_util::future::{ready, FutureExt as _, LocalBoxFuture, Ready, TryFutureExt as _};
use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};

use crate::{identity::IdentityItem, IdentityPolicy};

Expand Down Expand Up @@ -129,7 +130,8 @@ mod tests {

#[actix_rt::test]
async fn test_borrowed_mut_error() {
use futures_util::future::{lazy, ok, Ready};
use actix_utils::future::{ok, Ready};
use futures_util::future::lazy;

struct Ident;
impl IdentityPolicy for Ident {
Expand Down
2 changes: 1 addition & 1 deletion actix-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
description = "Protobuf support for Actix web"
keywords = ["actix", "protobuf", "protocol", "rpc"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras"
repository = "https://github.com/actix/actix-extras.git"
license = "MIT OR Apache-2.0"
exclude = [".cargo/config", "/examples/**"]

Expand Down
2 changes: 1 addition & 1 deletion actix-redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Redis integration for Actix and session store for Actix Web"
license = "MIT OR Apache-2.0"
keywords = ["actix", "redis", "async", "session"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras"
repository = "https://github.com/actix/actix-extras.git"
categories = ["network-programming", "asynchronous"]
exclude = [".cargo/config"]
edition = "2018"
Expand Down
5 changes: 3 additions & 2 deletions actix-session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Nikolay Kim <[email protected]>"]
description = "Sessions for Actix web"
keywords = ["http", "web", "framework", "async", "session"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras"
repository = "https://github.com/actix/actix-extras.git"
license = "MIT OR Apache-2.0"
edition = "2018"

Expand All @@ -18,8 +18,9 @@ default = ["cookie-session"]
cookie-session = ["actix-web/secure-cookies"]

[dependencies]
actix-web = { version = "4.0.0-beta.10", default_features = false, features = ["cookies"] }
actix-service = "2.0.0"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.10", default_features = false, features = ["cookies"] }

derive_more = "0.99.5"
futures-util = { version = "0.3.7", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion actix-session/src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::{collections::HashMap, error::Error as StdError, rc::Rc};

use actix_utils::future::{ok, Ready};
use actix_web::{
body::{AnyBody, MessageBody},
cookie::{Cookie, CookieJar, Key, SameSite},
Expand All @@ -10,7 +11,7 @@ use actix_web::{
Error, ResponseError,
};
use derive_more::Display;
use futures_util::future::{ok, FutureExt as _, LocalBoxFuture, Ready};
use futures_util::future::{FutureExt as _, LocalBoxFuture};
use serde_json::error::Error as JsonError;
use time::{Duration, OffsetDateTime};

Expand Down
2 changes: 1 addition & 1 deletion actix-session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ use std::{
rc::Rc,
};

use actix_utils::future::{ok, Ready};
use actix_web::{
dev::{Extensions, Payload, RequestHead, ServiceRequest, ServiceResponse},
Error, FromRequest, HttpMessage, HttpRequest,
};
use futures_util::future::{ok, Ready};
use serde::{de::DeserializeOwned, Serialize};

#[cfg(feature = "cookie-session")]
Expand Down
5 changes: 4 additions & 1 deletion actix-web-httpauth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ name = "actix_web_httpauth"
path = "src/lib.rs"

[dependencies]
actix-web = { version = "4.0.0-beta.10", default_features = false }
actix-service = "2.0.0"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.10", default_features = false }

base64 = "0.13"
futures-util = { version = "0.3.7", default-features = false }
futures-core = { version = "0.3.7", default-features = false }
pin-project-lite = "0.2.7"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion actix-web-httpauth/src/extractors/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
use std::borrow::Cow;

use actix_utils::future::{ready, Ready};
use actix_web::dev::{Payload, ServiceRequest};
use actix_web::http::header::Header;
use actix_web::{FromRequest, HttpRequest};
use futures_util::future::{ready, Ready};

use super::config::AuthExtractorConfig;
use super::errors::AuthenticationError;
Expand Down
24 changes: 11 additions & 13 deletions actix-web-httpauth/src/extractors/bearer.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
//! Extractor for the "Bearer" HTTP Authentication Scheme
use std::borrow::Cow;
use std::default::Default;

use actix_web::dev::{Payload, ServiceRequest};
use actix_web::http::header::Header;
use actix_web::{FromRequest, HttpRequest};
use futures_util::future::{ready, Ready};

use super::config::AuthExtractorConfig;
use super::errors::AuthenticationError;
use super::AuthExtractor;
use crate::headers::authorization;
use crate::headers::www_authenticate::bearer;
use std::{borrow::Cow, default::Default};

use actix_utils::future::{ready, Ready};
use actix_web::{
dev::{Payload, ServiceRequest},
http::header::Header,
FromRequest, HttpRequest,
};

use super::{config::AuthExtractorConfig, errors::AuthenticationError, AuthExtractor};
pub use crate::headers::www_authenticate::bearer::Error;
use crate::headers::{authorization, www_authenticate::bearer};

/// [BearerAuth](./struct/BearerAuth.html) extractor configuration.
#[derive(Debug, Clone, Default)]
Expand Down
2 changes: 1 addition & 1 deletion actix-web-httpauth/src/extractors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

use actix_web::dev::ServiceRequest;
use actix_web::Error;
use futures_util::ready;
use futures_core::ready;
use pin_project_lite::pin_project;

pub mod basic;
Expand Down
15 changes: 9 additions & 6 deletions actix-web-httpauth/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//! HTTP Authentication middleware.
use std::{
error::Error as StdError, future::Future, marker::PhantomData, pin::Pin, rc::Rc, sync::Arc,
error::Error as StdError,
future::Future,
marker::PhantomData,
pin::Pin,
rc::Rc,
sync::Arc,
task::{Context, Poll},
};

use actix_web::{
body::{AnyBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error,
};
use futures_util::{
future::{self, FutureExt as _, LocalBoxFuture, TryFutureExt as _},
ready,
task::{Context, Poll},
};
use futures_core::ready;
use futures_util::future::{self, FutureExt as _, LocalBoxFuture, TryFutureExt as _};

use crate::extractors::{basic, bearer, AuthExtractor};

Expand Down

0 comments on commit 5605178

Please sign in to comment.