Add minimal example, some formatting, bump parking_lot version
This commit is contained in:
+12
-14
@@ -1,6 +1,12 @@
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Add;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
|
||||
use rand::{rngs::OsRng, Rng};
|
||||
|
||||
use rocket::{
|
||||
fairing::{self, Fairing, Info},
|
||||
http::{Cookie, Status},
|
||||
@@ -9,13 +15,6 @@ use rocket::{
|
||||
Build, Request, Response, Rocket, State,
|
||||
};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Add;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// Session store (shared state)
|
||||
#[derive(Debug)]
|
||||
pub struct SessionStore<D>
|
||||
@@ -134,11 +133,10 @@ where
|
||||
let store_ug = store.inner.upgradable_read();
|
||||
|
||||
// Resolve session ID
|
||||
let id = if let Some(cookie) = request.cookies().get(&store.config.cookie_name) {
|
||||
Some(SessionID(cookie.value().to_string()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let id = request
|
||||
.cookies()
|
||||
.get(&store.config.cookie_name)
|
||||
.map(|cookie| SessionID(cookie.value().to_string()));
|
||||
|
||||
let expires = Instant::now().add(store.config.lifespan);
|
||||
|
||||
@@ -200,7 +198,7 @@ where
|
||||
new_id
|
||||
}
|
||||
}),
|
||||
store: store,
|
||||
store,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user