diff --git a/Cargo.lock b/Cargo.lock index d2b9b9e..d28fccb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "actix-cors" -version = "0.6.5" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" +checksum = "f9e772b3bcafe335042b5db010ab7c09013dad6eac4915c91d8d50902769f331" dependencies = [ "actix-utils", "actix-web", @@ -218,9 +218,9 @@ dependencies = [ [[package]] name = "actix-identity" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e1cc6f95e245b2f3c6995df4e1c0c697704c48c28ec325d135a3ca039d4952" +checksum = "1478456bca71c7b04411da1afb0c506e16dec6863815207693b791247511027f" dependencies = [ "actix-service", "actix-session", @@ -367,9 +367,9 @@ dependencies = [ [[package]] name = "actix-session" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e6a28f813a6671e1847d005cad0be36ae4d016287690f765c303379837c13d6" +checksum = "b671404ec72194d8af58c2bdaf51e3c477a0595056bd5010148405870dda8df2" dependencies = [ "actix", "actix-redis", @@ -377,7 +377,6 @@ dependencies = [ "actix-utils", "actix-web", "anyhow", - "async-trait", "derive_more", "futures-core", "rand 0.8.5", @@ -411,20 +410,19 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72616e7fbec0aa99c6f3164677fa48ff5a60036d0799c98cab894a44f3e0efc3" +checksum = "929e47cc23865cdb856e59673cfba2d28f00b3bbd060dfc80e33a00a3cea8317" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", "http 0.2.9", + "http 1.0.0", "impl-more", "openssl", "pin-project-lite 0.2.13", - "rustls 0.21.10", - "rustls-webpki", "tokio 1.35.1", "tokio-openssl", "tokio-rustls 0.23.4", @@ -2948,16 +2946,26 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" +name = "env_filter" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ - "humantime", - "is-terminal", "log", "regex", - "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", ] [[package]] @@ -4175,17 +4183,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.11.0" @@ -8197,7 +8194,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index 6746d53..6dfb996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,16 +77,16 @@ rust-version = "1.72" actix = "0.13" actix-broker = "0.4" actix-codec = "0.5" -actix-cors = "0.6" +actix-cors = "0.7" actix-files = "0.6" actix-http = "3.5" -actix-identity = "0.6" +actix-identity = "0.7" actix-multipart = "0.6" actix-multipart-derive = "0.6" actix-protobuf = "0.10" -actix-session = "0.8" +actix-session = "0.9" actix-test = "0.1" -actix-tls = "3.1.1" +actix-tls = "3.2" actix-utils = "3" actix-web = "4.4" actix-web-actors = "4.1" @@ -97,7 +97,7 @@ awc = "3.2" chrono = { version = "0.4.20", default-features = false, features = ["clock", "serde"] } derive_more = "0.99.7" dotenvy = "0.15" -env_logger = "0.10" +env_logger = "0.11" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } log = "0.4" openssl = { version = "0.10.60", features = ["v110"] } diff --git a/json/json-decode-error/Cargo.toml b/json/json-decode-error/Cargo.toml index 1ec786d..91c8f5a 100644 --- a/json/json-decode-error/Cargo.toml +++ b/json/json-decode-error/Cargo.toml @@ -8,4 +8,4 @@ actix-web.workspace = true env_logger.workspace = true log.workspace = true -serde = "1" +serde.workspace = true diff --git a/json/json-decode-error/src/main.rs b/json/json-decode-error/src/main.rs index eed6819..c9f87fd 100644 --- a/json/json-decode-error/src/main.rs +++ b/json/json-decode-error/src/main.rs @@ -1,7 +1,7 @@ use actix_web::{error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Debug, Deserialize)] struct Info { name: String, } @@ -38,6 +38,7 @@ async fn main() -> std::io::Result<()> { .error_handler(json_error_handler), ) }) + .workers(2) .bind(("127.0.0.1", 8080))? .run() .await diff --git a/json/json-error/src/main.rs b/json/json-error/src/main.rs index dda7c3a..2e4d06a 100644 --- a/json/json-error/src/main.rs +++ b/json/json-error/src/main.rs @@ -1,13 +1,9 @@ //! This example is meant to show how to automatically generate a json error response when something goes wrong. -use std::{ - fmt::{Display, Formatter, Result as FmtResult}, - io, -}; +use std::{fmt, io}; use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer, ResponseError}; use serde::Serialize; -use serde_json::{json, to_string_pretty}; #[derive(Debug, Serialize)] struct Error { @@ -15,16 +11,16 @@ struct Error { status: u16, } -impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> FmtResult { - write!(f, "{}", to_string_pretty(self).unwrap()) +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", serde_json::to_string_pretty(self).unwrap()) } } impl ResponseError for Error { // builds the actual response to send back when an error occurs fn error_response(&self) -> HttpResponse { - let err_json = json!({ "error": self.msg }); + let err_json = serde_json::json!({ "error": self.msg }); HttpResponse::build(StatusCode::from_u16(self.status).unwrap()).json(err_json) } } @@ -43,6 +39,7 @@ async fn main() -> io::Result<()> { log::info!("starting HTTP server at http://localhost:8080"); HttpServer::new(|| App::new().service(web::resource("/").route(web::get().to(index)))) + .workers(2) .bind(("127.0.0.1", 8080))? .run() .await