diff --git a/Cargo.lock b/Cargo.lock index d6124a0..984f1fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -501,7 +501,6 @@ dependencies = [ "actix-cors", "actix-web", "env_logger", - "futures", "serde 1.0.136", "serde_json", ] @@ -2794,7 +2793,7 @@ version = "1.0.0" dependencies = [ "actix-web", "env_logger", - "futures", + "futures-util", "json", "serde 1.0.136", "serde_json", @@ -2807,7 +2806,7 @@ dependencies = [ "actix-web", "awc", "env_logger", - "futures", + "futures-util", "log", "serde 1.0.136", "serde_json", @@ -2828,7 +2827,6 @@ name = "json_error" version = "1.0.0" dependencies = [ "actix-web", - "failure", "serde 1.0.136", "serde_json", ] @@ -3251,7 +3249,6 @@ name = "mongodb" version = "1.0.0" dependencies = [ "actix-web", - "futures-util", "mongodb 2.1.0", "serde 1.0.136", ] @@ -3341,7 +3338,7 @@ dependencies = [ "actix-web", "dotenv", "env_logger", - "futures", + "futures-util", "log", "rusoto_core", "rusoto_s3", @@ -3615,7 +3612,6 @@ dependencies = [ "actix-web", "anyhow", "env_logger", - "futures-util", "log", "openssl", "reqwest 0.11.9", @@ -4058,7 +4054,6 @@ dependencies = [ name = "protobuf-example" version = "1.0.0" dependencies = [ - "actix 0.13.0", "actix-protobuf", "actix-web", "env_logger", @@ -5044,7 +5039,6 @@ version = "1.0.0" dependencies = [ "actix-web", "env_logger", - "futures", "tokio 1.17.0", ] @@ -5068,7 +5062,6 @@ dependencies = [ "diesel", "dotenv", "env_logger", - "futures", "lazy_static", "r2d2", "rust-argon2", @@ -5684,7 +5677,6 @@ dependencies = [ "actix-web", "dotenv", "env_logger", - "futures-util", "log", "serde 1.0.136", "serde_json", @@ -6485,7 +6477,7 @@ dependencies = [ "actix-web-actors", "awc", "env_logger", - "futures", + "futures-util", "log", "tokio 1.17.0", "tokio-stream", @@ -6543,7 +6535,7 @@ dependencies = [ "byteorder", "bytes 1.1.0", "env_logger", - "futures", + "futures-util", "log", "rand 0.8.5", "serde 1.0.136", diff --git a/auth/simple-auth-server/Cargo.toml b/auth/simple-auth-server/Cargo.toml index 42cf764..7c04ce5 100644 --- a/auth/simple-auth-server/Cargo.toml +++ b/auth/simple-auth-server/Cargo.toml @@ -7,17 +7,16 @@ edition = "2021" actix-web = "4" actix-identity = "0.4" -chrono = { version = "0.4.6", features = ["serde"] } -derive_more = "0.99.0" +chrono = { version = "0.4", features = ["serde"] } +derive_more = "0.99.5" diesel = { version = "1.4.5", features = ["postgres", "uuidv07", "r2d2", "chrono"] } dotenv = "0.15" -env_logger = "0.9.0" -futures = "0.3.1" +env_logger = "0.9" r2d2 = "0.8" -rust-argon2 = "1.0.0" -lazy_static = "1.4.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -sparkpost = "0.5.2" -uuid = { version = "0.8.2", features = ["serde", "v4"] } -time = "0.3.7" +rust-argon2 = "1" +lazy_static = "1.4" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +sparkpost = "0.5" +uuid = { version = "0.8", features = ["serde", "v4"] } +time = "0.3" diff --git a/auth/simple-auth-server/src/auth_handler.rs b/auth/simple-auth-server/src/auth_handler.rs index 9af6dca..b4b0942 100644 --- a/auth/simple-auth-server/src/auth_handler.rs +++ b/auth/simple-auth-server/src/auth_handler.rs @@ -1,8 +1,9 @@ +use std::future::{ready, Ready}; + use actix_identity::Identity; use actix_web::{dev::Payload, web, Error, FromRequest, HttpRequest, HttpResponse}; use diesel::prelude::*; use diesel::PgConnection; -use futures::future::{err, ok, Ready}; use serde::Deserialize; use crate::errors::ServiceError; @@ -27,11 +28,12 @@ impl FromRequest for LoggedUser { if let Ok(identity) = Identity::from_request(req, pl).into_inner() { if let Some(user_json) = identity.identity() { if let Ok(user) = serde_json::from_str(&user_json) { - return ok(user); + return ready(Ok(user)); } } } - err(ServiceError::Unauthorized.into()) + + ready(Err(ServiceError::Unauthorized.into())) } } diff --git a/basics/todo/Cargo.toml b/basics/todo/Cargo.toml index d47dac9..fcb609b 100644 --- a/basics/todo/Cargo.toml +++ b/basics/todo/Cargo.toml @@ -10,12 +10,8 @@ actix-session = "0.5" dotenv = "0.15" env_logger = "0.9" -futures-util = "0.3.7" log = "0.4" serde = { version = "1", features = ["derive"] } serde_json = "1" +sqlx = { version = "0.5.10", features = ["runtime-tokio-rustls", "sqlite", "offline"] } tera = "1.5" - -[dependencies.sqlx] -features = ["runtime-tokio-rustls", "sqlite", "offline"] -version = "0.5.10" diff --git a/cors/backend/Cargo.toml b/cors/backend/Cargo.toml index 07300e4..cf103dc 100644 --- a/cors/backend/Cargo.toml +++ b/cors/backend/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" actix-web = { version = "4", features = ["rustls"] } actix-cors = "0.6" +env_logger = "0.9" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -env_logger = "0.9" -futures = "0.3" diff --git a/databases/diesel/Cargo.toml b/databases/diesel/Cargo.toml index 31da921..3653229 100644 --- a/databases/diesel/Cargo.toml +++ b/databases/diesel/Cargo.toml @@ -8,8 +8,6 @@ actix-web = "4" diesel = { version = "1.4.8", features = ["sqlite", "r2d2"] } dotenv = "0.15" env_logger = "0.9.0" -failure = "0.1.8" -futures = "0.3.1" log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/databases/mongodb/Cargo.toml b/databases/mongodb/Cargo.toml index 085b834..386d06a 100644 --- a/databases/mongodb/Cargo.toml +++ b/databases/mongodb/Cargo.toml @@ -5,6 +5,5 @@ edition = "2021" [dependencies] actix-web = "4" -futures-util = "0.3.17" mongodb = "2.0.0" serde = { version = "1.0", features = ["derive"] } diff --git a/forms/multipart-s3/Cargo.toml b/forms/multipart-s3/Cargo.toml index 49b5e9f..a26e341 100644 --- a/forms/multipart-s3/Cargo.toml +++ b/forms/multipart-s3/Cargo.toml @@ -9,7 +9,7 @@ actix-multipart = "0.4" dotenv = "0.15.0" env_logger = "0.9" -futures = "0.3.1" +futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" rusoto_core = "0.47.0" rusoto_s3 = "0.47.0" diff --git a/forms/multipart-s3/src/utils/upload.rs b/forms/multipart-s3/src/utils/upload.rs index a35e8eb..04717ba 100644 --- a/forms/multipart-s3/src/utils/upload.rs +++ b/forms/multipart-s3/src/utils/upload.rs @@ -1,7 +1,7 @@ use crate::utils::s3::Client; use actix_multipart::{Field, Multipart}; use actix_web::{web, web::Bytes, Error}; -use futures::StreamExt; +use futures_util::StreamExt as _; use serde::{Deserialize, Serialize}; use std::convert::From; use std::io::Write; diff --git a/forms/multipart/Cargo.toml b/forms/multipart/Cargo.toml index a454ec4..804bd32 100644 --- a/forms/multipart/Cargo.toml +++ b/forms/multipart/Cargo.toml @@ -12,6 +12,6 @@ readme = "README.md" actix-multipart = "0.4" actix-web = "4" -futures-util = "0.3" +futures-util = { version = "0.3.7", default-features = false, features = ["std"] } sanitize-filename = "0.3" uuid = { version = "0.8", features = ["v4"] } diff --git a/guards/src/main.rs b/guards/src/main.rs index 059a9d6..bbc4060 100644 --- a/guards/src/main.rs +++ b/guards/src/main.rs @@ -71,3 +71,23 @@ async fn main() -> std::io::Result<()> { .run() .await } + +#[cfg(test)] +mod tests { + use actix_web::test::{self, TestRequest}; + + use super::*; + + #[actix_web::test] + async fn api_versioning() { + let app = test::init_service(create_app()).await; + + let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "1")); + let res = test::call_and_read_body(&app, req.to_request()).await; + assert_eq!(res, "Hello World from v1 API!"); + + let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "2")); + let res = test::call_and_read_body(&app, req.to_request()).await; + assert_eq!(res, "Hello World from the awesome new v2 API!"); + } +} diff --git a/https-tls/openssl-auto-le/Cargo.toml b/https-tls/openssl-auto-le/Cargo.toml index d17a286..57ad092 100644 --- a/https-tls/openssl-auto-le/Cargo.toml +++ b/https-tls/openssl-auto-le/Cargo.toml @@ -10,7 +10,6 @@ actix-files = "0.6" acme-micro = "0.12" anyhow = "1" env_logger = "0.9" -futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" openssl = { version = "0.10", features = ["v110"] } reqwest = "0.11" diff --git a/json/json-error/Cargo.toml b/json/json-error/Cargo.toml index 0d27872..dbd0a71 100644 --- a/json/json-error/Cargo.toml +++ b/json/json-error/Cargo.toml @@ -5,6 +5,5 @@ edition = "2021" [dependencies] actix-web = "4" -failure = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/json/json-validation/Cargo.toml b/json/json-validation/Cargo.toml index a87d11f..8b97480 100644 --- a/json/json-validation/Cargo.toml +++ b/json/json-validation/Cargo.toml @@ -8,7 +8,7 @@ actix-web = "4" awc = { version = "3.0.0-beta.21", features = ["openssl"] } env_logger = "0.9" -futures = "0.3.1" +futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" serde = { version = "1.0.43", features = ["derive"] } serde_json = "1.0.16" diff --git a/json/json-validation/src/main.rs b/json/json-validation/src/main.rs index b7253b9..250b8f8 100644 --- a/json/json-validation/src/main.rs +++ b/json/json-validation/src/main.rs @@ -21,7 +21,7 @@ use actix_web::{ App, Error, HttpResponse, HttpServer, }; use awc::Client; -use futures::StreamExt; +use futures_util::StreamExt as _; use serde::{Deserialize, Serialize}; use validator::Validate; use validator_derive::Validate; diff --git a/json/json/Cargo.toml b/json/json/Cargo.toml index 47931cb..c4db84a 100644 --- a/json/json/Cargo.toml +++ b/json/json/Cargo.toml @@ -5,8 +5,9 @@ edition = "2021" [dependencies] actix-web = "4" -futures = "0.3" + env_logger = "0.9.0" +futures-util = { version = "0.3.7", default-features = false, features = ["std"] } +json = "0.12" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -json = "0.12" diff --git a/json/json/src/main.rs b/json/json/src/main.rs index 1311424..71bc8c4 100644 --- a/json/json/src/main.rs +++ b/json/json/src/main.rs @@ -1,5 +1,5 @@ use actix_web::{error, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; -use futures::StreamExt; +use futures_util::StreamExt as _; use json::JsonValue; use serde::{Deserialize, Serialize}; diff --git a/json/jsonrpc/Cargo.toml b/json/jsonrpc/Cargo.toml index e3f2f24..b5ee0b5 100644 --- a/json/jsonrpc/Cargo.toml +++ b/json/jsonrpc/Cargo.toml @@ -8,7 +8,7 @@ actix-web = "4" bytes = "1.1.0" env_logger = "0.9.0" -futures-util = "0.3" +futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.78" diff --git a/protobuf/Cargo.toml b/protobuf/Cargo.toml index 856cc58..08d51b1 100644 --- a/protobuf/Cargo.toml +++ b/protobuf/Cargo.toml @@ -4,9 +4,9 @@ version = "1.0.0" edition = "2021" [dependencies] -actix = "0.13" actix-protobuf = "0.7" actix-web = "4" + env_logger = "0.9" log = "0.4" prost = "0.9" diff --git a/shutdown-server/Cargo.toml b/shutdown-server/Cargo.toml index 1196adf..69b42a6 100644 --- a/shutdown-server/Cargo.toml +++ b/shutdown-server/Cargo.toml @@ -6,6 +6,6 @@ description = "Send a request to the server to shut it down" [dependencies] actix-web = "4" + env_logger = "0.9" -futures = "0.3" tokio = { version = "1.16", features = ["signal"] } diff --git a/shutdown-server/src/main.rs b/shutdown-server/src/main.rs index f7f208f..5667c19 100644 --- a/shutdown-server/src/main.rs +++ b/shutdown-server/src/main.rs @@ -1,5 +1,4 @@ use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer}; -use futures::executor; use std::{sync::mpsc, thread}; #[get("/hello")] @@ -37,16 +36,16 @@ async fn main() -> std::io::Result<()> { .bind(&bind)? .run(); - // clone the Server handle + // clone the server handle let srv = server.handle(); thread::spawn(move || { // wait for shutdown signal rx.recv().unwrap(); - // stop server gracefully - executor::block_on(srv.stop(true)) + // send stop server gracefully command + srv.stop(true) }); - // run server + // run server until stopped (either by ctrl-c or stop endpoint) server.await } diff --git a/websockets/chat-tcp/Cargo.toml b/websockets/chat-tcp/Cargo.toml index 454b05c..633b569 100644 --- a/websockets/chat-tcp/Cargo.toml +++ b/websockets/chat-tcp/Cargo.toml @@ -21,7 +21,7 @@ actix-web-actors = "4.1" byteorder = "1.2" bytes = "1" env_logger = "0.9" -futures = "0.3" +futures-util = { version = "0.3.7", default-features = false, features = ["std", "sink"] } log = "0.4" rand = "0.8" serde = { version = "1", features = ["derive"] } diff --git a/websockets/chat-tcp/src/client.rs b/websockets/chat-tcp/src/client.rs index 28a707e..b5c3951 100644 --- a/websockets/chat-tcp/src/client.rs +++ b/websockets/chat-tcp/src/client.rs @@ -1,6 +1,6 @@ use std::{io, thread}; -use futures::{SinkExt, StreamExt}; +use futures_util::{SinkExt as _, StreamExt as _}; use tokio::{net::TcpStream, select, sync::mpsc}; use tokio_stream::wrappers::UnboundedReceiverStream; diff --git a/websockets/echo/Cargo.toml b/websockets/echo/Cargo.toml index bf04bfd..0bf0af8 100644 --- a/websockets/echo/Cargo.toml +++ b/websockets/echo/Cargo.toml @@ -21,7 +21,7 @@ actix-web-actors = "4.1" awc = "3.0.0-beta.21" env_logger = "0.9" +futures-util = { version = "0.3.7", default-features = false, features = ["std", "sink"] } log = "0.4" -futures = "0.3.7" tokio = { version = "1.13.1", features = ["full"] } tokio-stream = "0.1.8" diff --git a/websockets/echo/src/client.rs b/websockets/echo/src/client.rs index 9f76781..b0e519d 100644 --- a/websockets/echo/src/client.rs +++ b/websockets/echo/src/client.rs @@ -4,7 +4,7 @@ use std::{io, thread}; use actix_web::web::Bytes; use awc::ws; -use futures::{SinkExt as _, StreamExt as _}; +use futures_util::{SinkExt as _, StreamExt as _}; use tokio::{select, sync::mpsc}; use tokio_stream::wrappers::UnboundedReceiverStream;