mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
update user_session sample (#292)
This commit is contained in:
parent
2bc48c18c8
commit
f6d103da57
@ -5,6 +5,6 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
actix-session = "0.5.0-beta.8"
|
||||
actix-session = { version = "0.7.2", features = ["cookie-session"] }
|
||||
futures-util = { version = "0.3.7", default-features = false, features = ["std"] }
|
||||
env_logger = "0.7"
|
||||
|
@ -1,8 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
// <user-session>
|
||||
use actix_session::{CookieSession, Session};
|
||||
use actix_web::{web, App, Error, HttpResponse, HttpServer};
|
||||
use actix_session::{Session, SessionMiddleware, storage::CookieSessionStore};
|
||||
use actix_web::{web, App, Error, HttpResponse, HttpServer, cookie::Key};
|
||||
|
||||
async fn index(session: Session) -> Result<HttpResponse, Error> {
|
||||
// access session data
|
||||
@ -23,8 +23,10 @@ async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.wrap(
|
||||
CookieSession::signed(&[0; 32]) // <- create cookie based session middleware
|
||||
.secure(false),
|
||||
// create cookie based session middleware
|
||||
SessionMiddleware::builder(CookieSessionStore::default(), Key::from(&[0; 64]))
|
||||
.cookie_secure(false)
|
||||
.build()
|
||||
)
|
||||
.service(web::resource("/").to(index))
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user