From 6e5b04c5704016b87f3f77f4f5ff69cf6212066e Mon Sep 17 00:00:00 2001 From: Luca Palmieri Date: Wed, 2 Feb 2022 15:22:50 +0000 Subject: [PATCH] Update session/cookie-session to v4 (#493) Co-authored-by: Rob Ede --- session/cookie-session/Cargo.toml | 7 ++++--- session/cookie-session/src/main.rs | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/session/cookie-session/Cargo.toml b/session/cookie-session/Cargo.toml index 29ce8d7f..3f09ee0a 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 feed64bf..973936bb 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()