1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00

chore: update root deps

This commit is contained in:
Rob Ede 2024-01-30 23:44:35 +00:00
parent 474f423556
commit dc3de98d46
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
5 changed files with 40 additions and 45 deletions

55
Cargo.lock generated
View File

@ -103,9 +103,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-cors" name = "actix-cors"
version = "0.6.5" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" checksum = "f9e772b3bcafe335042b5db010ab7c09013dad6eac4915c91d8d50902769f331"
dependencies = [ dependencies = [
"actix-utils", "actix-utils",
"actix-web", "actix-web",
@ -218,9 +218,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-identity" name = "actix-identity"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36e1cc6f95e245b2f3c6995df4e1c0c697704c48c28ec325d135a3ca039d4952" checksum = "1478456bca71c7b04411da1afb0c506e16dec6863815207693b791247511027f"
dependencies = [ dependencies = [
"actix-service", "actix-service",
"actix-session", "actix-session",
@ -367,9 +367,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-session" name = "actix-session"
version = "0.8.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e6a28f813a6671e1847d005cad0be36ae4d016287690f765c303379837c13d6" checksum = "b671404ec72194d8af58c2bdaf51e3c477a0595056bd5010148405870dda8df2"
dependencies = [ dependencies = [
"actix", "actix",
"actix-redis", "actix-redis",
@ -377,7 +377,6 @@ dependencies = [
"actix-utils", "actix-utils",
"actix-web", "actix-web",
"anyhow", "anyhow",
"async-trait",
"derive_more", "derive_more",
"futures-core", "futures-core",
"rand 0.8.5", "rand 0.8.5",
@ -411,20 +410,19 @@ dependencies = [
[[package]] [[package]]
name = "actix-tls" name = "actix-tls"
version = "3.1.1" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72616e7fbec0aa99c6f3164677fa48ff5a60036d0799c98cab894a44f3e0efc3" checksum = "929e47cc23865cdb856e59673cfba2d28f00b3bbd060dfc80e33a00a3cea8317"
dependencies = [ dependencies = [
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-utils", "actix-utils",
"futures-core", "futures-core",
"http 0.2.9", "http 0.2.9",
"http 1.0.0",
"impl-more", "impl-more",
"openssl", "openssl",
"pin-project-lite 0.2.13", "pin-project-lite 0.2.13",
"rustls 0.21.10",
"rustls-webpki",
"tokio 1.35.1", "tokio 1.35.1",
"tokio-openssl", "tokio-openssl",
"tokio-rustls 0.23.4", "tokio-rustls 0.23.4",
@ -2948,16 +2946,26 @@ dependencies = [
] ]
[[package]] [[package]]
name = "env_logger" name = "env_filter"
version = "0.10.2" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
dependencies = [ dependencies = [
"humantime",
"is-terminal",
"log", "log",
"regex", "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]] [[package]]
@ -4175,17 +4183,6 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" 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]] [[package]]
name = "itertools" name = "itertools"
version = "0.11.0" version = "0.11.0"
@ -8197,7 +8194,7 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 1.0.0",
"rand 0.8.5", "rand 0.8.5",
"static_assertions", "static_assertions",
] ]

View File

@ -77,16 +77,16 @@ rust-version = "1.72"
actix = "0.13" actix = "0.13"
actix-broker = "0.4" actix-broker = "0.4"
actix-codec = "0.5" actix-codec = "0.5"
actix-cors = "0.6" actix-cors = "0.7"
actix-files = "0.6" actix-files = "0.6"
actix-http = "3.5" actix-http = "3.5"
actix-identity = "0.6" actix-identity = "0.7"
actix-multipart = "0.6" actix-multipart = "0.6"
actix-multipart-derive = "0.6" actix-multipart-derive = "0.6"
actix-protobuf = "0.10" actix-protobuf = "0.10"
actix-session = "0.8" actix-session = "0.9"
actix-test = "0.1" actix-test = "0.1"
actix-tls = "3.1.1" actix-tls = "3.2"
actix-utils = "3" actix-utils = "3"
actix-web = "4.4" actix-web = "4.4"
actix-web-actors = "4.1" actix-web-actors = "4.1"
@ -97,7 +97,7 @@ awc = "3.2"
chrono = { version = "0.4.20", default-features = false, features = ["clock", "serde"] } chrono = { version = "0.4.20", default-features = false, features = ["clock", "serde"] }
derive_more = "0.99.7" derive_more = "0.99.7"
dotenvy = "0.15" dotenvy = "0.15"
env_logger = "0.10" env_logger = "0.11"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
log = "0.4" log = "0.4"
openssl = { version = "0.10.60", features = ["v110"] } openssl = { version = "0.10.60", features = ["v110"] }

View File

@ -8,4 +8,4 @@ actix-web.workspace = true
env_logger.workspace = true env_logger.workspace = true
log.workspace = true log.workspace = true
serde = "1" serde.workspace = true

View File

@ -1,7 +1,7 @@
use actix_web::{error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use actix_web::{error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
use serde::Deserialize; use serde::Deserialize;
#[derive(Deserialize)] #[derive(Debug, Deserialize)]
struct Info { struct Info {
name: String, name: String,
} }
@ -38,6 +38,7 @@ async fn main() -> std::io::Result<()> {
.error_handler(json_error_handler), .error_handler(json_error_handler),
) )
}) })
.workers(2)
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", 8080))?
.run() .run()
.await .await

View File

@ -1,13 +1,9 @@
//! This example is meant to show how to automatically generate a json error response when something goes wrong. //! This example is meant to show how to automatically generate a json error response when something goes wrong.
use std::{ use std::{fmt, io};
fmt::{Display, Formatter, Result as FmtResult},
io,
};
use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer, ResponseError}; use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer, ResponseError};
use serde::Serialize; use serde::Serialize;
use serde_json::{json, to_string_pretty};
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
struct Error { struct Error {
@ -15,16 +11,16 @@ struct Error {
status: u16, status: u16,
} }
impl Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut Formatter) -> FmtResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", to_string_pretty(self).unwrap()) write!(f, "{}", serde_json::to_string_pretty(self).unwrap())
} }
} }
impl ResponseError for Error { impl ResponseError for Error {
// builds the actual response to send back when an error occurs // builds the actual response to send back when an error occurs
fn error_response(&self) -> HttpResponse { 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) 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"); log::info!("starting HTTP server at http://localhost:8080");
HttpServer::new(|| App::new().service(web::resource("/").route(web::get().to(index)))) HttpServer::new(|| App::new().service(web::resource("/").route(web::get().to(index))))
.workers(2)
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", 8080))?
.run() .run()
.await .await