mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
Updated actix-session version to 0.6 in examples/auth/cookie-session (#560)
This commit is contained in:
@ -5,6 +5,6 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
actix-session = "0.5"
|
||||
actix-session = { version = "0.6", features = ["cookie-session"] }
|
||||
log = "0.4"
|
||||
env_logger = "0.9"
|
||||
|
@ -5,8 +5,8 @@
|
||||
//!
|
||||
//! [User guide](https://actix.rs/docs/middleware/#user-sessions)
|
||||
|
||||
use actix_session::{CookieSession, Session};
|
||||
use actix_web::{middleware::Logger, web, App, HttpRequest, HttpServer, Result};
|
||||
use actix_session::{storage::CookieSessionStore, Session, SessionMiddleware};
|
||||
use actix_web::{cookie::Key, middleware::Logger, web, App, HttpRequest, HttpServer, Result};
|
||||
|
||||
/// simple index handler with session
|
||||
async fn index(session: Session, req: HttpRequest) -> Result<&'static str> {
|
||||
@ -27,7 +27,7 @@ async fn index(session: Session, req: HttpRequest) -> Result<&'static str> {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
std::env::set_var("RUST_LOG", "info");
|
||||
env_logger::init();
|
||||
log::info!("Starting http server: 127.0.0.1:8080");
|
||||
|
||||
@ -36,7 +36,11 @@ async fn main() -> std::io::Result<()> {
|
||||
// enable logger
|
||||
.wrap(Logger::default())
|
||||
// cookie session middleware
|
||||
.wrap(CookieSession::signed(&[0; 32]).secure(false))
|
||||
.wrap(
|
||||
SessionMiddleware::builder(CookieSessionStore::default(), Key::from(&[0; 64]))
|
||||
.cookie_secure(false)
|
||||
.build(),
|
||||
)
|
||||
.service(web::resource("/").to(index))
|
||||
})
|
||||
.bind(("127.0.0.1", 8080))?
|
||||
|
Reference in New Issue
Block a user