Struct tower_sessions::SessionManagerLayer
source · pub struct SessionManagerLayer<Store: SessionStore> { /* private fields */ }Expand description
A layer for providing Session as a request extension.
Implementations§
source§impl<Store: SessionStore> SessionManagerLayer<Store>
impl<Store: SessionStore> SessionManagerLayer<Store>
sourcepub fn with_name(self, name: &str) -> Self
pub fn with_name(self, name: &str) -> Self
Configures the name of the cookie used for the session.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store).with_name("my.sid");sourcepub fn with_same_site(self, same_site: SameSite) -> Self
pub fn with_same_site(self, same_site: SameSite) -> Self
Configures the "SameSite" attribute of the cookie used for the
session.
Examples
use tower_sessions::{cookie::SameSite, MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store).with_same_site(SameSite::Lax);sourcepub fn with_max_age(self, max_age: Duration) -> Self
pub fn with_max_age(self, max_age: Duration) -> Self
Configures the "Max-Age" attribute of the cookie used for the session.
Examples
use time::Duration;
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store).with_max_age(Duration::hours(1));sourcepub fn with_secure(self, secure: bool) -> Self
pub fn with_secure(self, secure: bool) -> Self
Configures the "Secure" attribute of the cookie used for the session.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store).with_secure(true);sourcepub fn with_path(self, path: String) -> Self
pub fn with_path(self, path: String) -> Self
Configures the "Path" attribute of the cookie used for the session.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service =
SessionManagerLayer::new(session_store).with_path("/some/path".to_string());sourcepub fn with_domain(self, domain: String) -> Self
pub fn with_domain(self, domain: String) -> Self
Configures the "Domain" attribute of the cookie used for the session.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service =
SessionManagerLayer::new(session_store).with_domain("localhost".to_string());source§impl<Store: SessionStore> SessionManagerLayer<Store>
impl<Store: SessionStore> SessionManagerLayer<Store>
sourcepub fn new(session_store: Store) -> Self
pub fn new(session_store: Store) -> Self
Create a new SessionManagerLayer with the provided session store
and default cookie configuration.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store);Trait Implementations§
source§impl<Store: Clone + SessionStore> Clone for SessionManagerLayer<Store>
impl<Store: Clone + SessionStore> Clone for SessionManagerLayer<Store>
source§fn clone(&self) -> SessionManagerLayer<Store>
fn clone(&self) -> SessionManagerLayer<Store>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<Store: Debug + SessionStore> Debug for SessionManagerLayer<Store>
impl<Store: Debug + SessionStore> Debug for SessionManagerLayer<Store>
source§impl<S, Store: SessionStore> Layer<S> for SessionManagerLayer<Store>
impl<S, Store: SessionStore> Layer<S> for SessionManagerLayer<Store>
§type Service = CookieManager<SessionManager<S, Store>>
type Service = CookieManager<SessionManager<S, Store>>
The wrapped service
Auto Trait Implementations§
impl<Store> RefUnwindSafe for SessionManagerLayer<Store>where Store: RefUnwindSafe,
impl<Store> Send for SessionManagerLayer<Store>
impl<Store> Sync for SessionManagerLayer<Store>
impl<Store> Unpin for SessionManagerLayer<Store>where Store: Unpin,
impl<Store> UnwindSafe for SessionManagerLayer<Store>where Store: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more