Skip to content

Commit

Permalink
reduce futures dep
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Mar 6, 2022
1 parent c5f2a8f commit e8cd22d
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 59 deletions.
18 changes: 5 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions auth/simple-auth-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 5 additions & 3 deletions auth/simple-auth-server/src/auth_handler.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()))
}
}

Expand Down
6 changes: 1 addition & 5 deletions basics/todo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 1 addition & 2 deletions cors/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions databases/diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion databases/mongodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion forms/multipart-s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion forms/multipart-s3/src/utils/upload.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion forms/multipart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
20 changes: 20 additions & 0 deletions guards/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
}
1 change: 0 additions & 1 deletion https-tls/openssl-auto-le/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion json/json-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ edition = "2021"

[dependencies]
actix-web = "4"
failure = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
2 changes: 1 addition & 1 deletion json/json-validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion json/json-validation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions json/json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion json/json/src/main.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion json/jsonrpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion shutdown-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
9 changes: 4 additions & 5 deletions shutdown-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer};
use futures::executor;
use std::{sync::mpsc, thread};

#[get("/hello")]
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion websockets/chat-tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion websockets/chat-tcp/src/client.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion websockets/echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion websockets/echo/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e8cd22d

Please sign in to comment.