diff --git a/session/cookie-session/Cargo.toml b/session/cookie-session/Cargo.toml index 29ce8d7..3f09ee0 100644 --- a/session/cookie-session/Cargo.toml +++ b/session/cookie-session/Cargo.toml @@ -4,6 +4,7 @@ version = "1.0.0" edition = "2021" [dependencies] -actix-web = "3" -actix-session = "0.4" -env_logger = "0.8" +actix-web = "4.0.0-beta.21" +actix-session = "0.5.0-beta.7" +log = "0.4" +env_logger = "0.9.0" diff --git a/session/cookie-session/src/main.rs b/session/cookie-session/src/main.rs index feed64b..973936b 100644 --- a/session/cookie-session/src/main.rs +++ b/session/cookie-session/src/main.rs @@ -10,16 +10,16 @@ use actix_web::{middleware::Logger, web, App, HttpRequest, HttpServer, Result}; /// simple index handler with session async fn index(session: Session, req: HttpRequest) -> Result<&'static str> { - println!("{:?}", req); + log::info!("{:?}", req); // RequestSession trait is used for session access let mut counter = 1; if let Some(count) = session.get::("counter")? { - println!("SESSION value: {}", count); + log::info!("SESSION value: {}", count); counter = count + 1; - session.set("counter", counter)?; + session.insert("counter", counter)?; } else { - session.set("counter", counter)?; + session.insert("counter", counter)?; } Ok("welcome!") @@ -29,7 +29,7 @@ async fn index(session: Session, req: HttpRequest) -> Result<&'static str> { async fn main() -> std::io::Result<()> { std::env::set_var("RUST_LOG", "actix_web=info"); env_logger::init(); - println!("Starting http server: 127.0.0.1:8080"); + log::info!("Starting http server: 127.0.0.1:8080"); HttpServer::new(|| { App::new()