diff --git a/actix-ws/Cargo.toml b/actix-ws/Cargo.toml index 7b7425af5..d489fa0cd 100644 --- a/actix-ws/Cargo.toml +++ b/actix-ws/Cargo.toml @@ -23,9 +23,9 @@ tokio = { version = "1", features = ["sync"] } [dev-dependencies] actix-rt = "2.6" -actix-web = "4.0.1" -anyhow = "1.0" -futures-util = "0.3.17" +actix-web = "4.8" +anyhow = "1" +futures-util = { version = "0.3.17", default-features = false, features = ["std"] } log = "0.4" pretty_env_logger = "0.5" tokio = { version = "1", features = ["sync"] } diff --git a/actix-ws/examples/chat.html b/actix-ws/examples/chat.html new file mode 100644 index 000000000..3d6ea1266 --- /dev/null +++ b/actix-ws/examples/chat.html @@ -0,0 +1,69 @@ + + + + Chat + + + + + + + diff --git a/actix-ws/examples/chat.rs b/actix-ws/examples/chat.rs index ea034df89..cea98e2a7 100644 --- a/actix-ws/examples/chat.rs +++ b/actix-ws/examples/chat.rs @@ -3,7 +3,9 @@ use std::{ time::{Duration, Instant}, }; -use actix_web::{middleware::Logger, web, App, HttpRequest, HttpResponse, HttpServer}; +use actix_web::{ + middleware::Logger, web, web::Html, App, HttpRequest, HttpResponse, HttpServer, Responder, +}; use actix_ws::{Message, Session}; use futures_util::{stream::FuturesUnordered, StreamExt as _}; use log::info; @@ -116,75 +118,8 @@ async fn ws( Ok(response) } -async fn index() -> HttpResponse { - let s = r#" - - - - Chat - - - - - - - - "#; - - HttpResponse::Ok().content_type("text/html").body(s) +async fn index() -> impl Responder { + Html::new(include_str!("chat.html").to_owned()) } #[actix_rt::main]