diff --git a/tracing/mainmatter-workshop/src/middleware.rs b/tracing/mainmatter-workshop/src/middleware.rs index 130ded8..06748e1 100644 --- a/tracing/mainmatter-workshop/src/middleware.rs +++ b/tracing/mainmatter-workshop/src/middleware.rs @@ -1,10 +1,10 @@ use std::time::Instant; -use actix_web::HttpMessage as _; use actix_web::{ body::MessageBody, dev::{ServiceRequest, ServiceResponse}, http::header::{HeaderName, HeaderValue}, + HttpMessage as _, }; use actix_web_lab::middleware::Next; use tracing_actix_web::RequestId; diff --git a/websockets/autobahn/src/main.rs b/websockets/autobahn/src/main.rs index dd4388b..1918cff 100644 --- a/websockets/autobahn/src/main.rs +++ b/websockets/autobahn/src/main.rs @@ -32,6 +32,7 @@ impl StreamHandler> for AutobahnWebSocket } } +// the actor-based WebSocket examples REQUIRE `actix_web::main` for actor support #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/chat-actorless/src/main.rs b/websockets/chat-actorless/src/main.rs index c5cd144..dec775b 100644 --- a/websockets/chat-actorless/src/main.rs +++ b/websockets/chat-actorless/src/main.rs @@ -47,7 +47,6 @@ async fn chat_ws( Ok(res) } -// note that the actor-based WebSocket examples would NOT work under `tokio::main` #[tokio::main(flavor = "current_thread")] async fn main() -> io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/chat-broker/src/main.rs b/websockets/chat-broker/src/main.rs index 8f4a2b5..efd7ed2 100644 --- a/websockets/chat-broker/src/main.rs +++ b/websockets/chat-broker/src/main.rs @@ -16,6 +16,7 @@ async fn chat_ws(req: HttpRequest, stream: web::Payload) -> Result std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/chat-tcp/src/main.rs b/websockets/chat-tcp/src/main.rs index f94113f..65f8bc7 100644 --- a/websockets/chat-tcp/src/main.rs +++ b/websockets/chat-tcp/src/main.rs @@ -220,6 +220,7 @@ impl WsChatSession { } } +// the actor-based WebSocket examples REQUIRE `actix_web::main` for actor support #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/chat/src/main.rs b/websockets/chat/src/main.rs index 88c35ab..0cb742d 100644 --- a/websockets/chat/src/main.rs +++ b/websockets/chat/src/main.rs @@ -45,6 +45,7 @@ async fn get_count(count: web::Data) -> impl Responder { format!("Visitors: {current_count}") } +// the actor-based WebSocket examples REQUIRE `actix_web::main` for actor support #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/echo-actorless/src/main.rs b/websockets/echo-actorless/src/main.rs index fb8abcb..e40c7bd 100644 --- a/websockets/echo-actorless/src/main.rs +++ b/websockets/echo-actorless/src/main.rs @@ -65,7 +65,6 @@ async fn broadcast_ws( Ok(res) } -// note that the actor-based WebSocket examples would NOT work under `tokio::main` #[tokio::main(flavor = "current_thread")] async fn main() -> io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); diff --git a/websockets/echo/src/main.rs b/websockets/echo/src/main.rs index 5a06497..7a6d656 100644 --- a/websockets/echo/src/main.rs +++ b/websockets/echo/src/main.rs @@ -18,6 +18,7 @@ async fn echo_ws(req: HttpRequest, stream: web::Payload) -> Result std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));