Struct tower_sessions::SessionManagerLayer
source ยท pub struct SessionManagerLayer<Store>where
Store: SessionStore,{ /* private fields */ }Expand description
A layer for providing Session as a request extension.
Implementationsยง
sourceยงimpl<Store> SessionManagerLayer<Store>where
Store: SessionStore,
impl<Store> SessionManagerLayer<Store>where
Store: SessionStore,
sourcepub fn with_name(self, name: &str) -> SessionManagerLayer<Store>
pub fn with_name(self, name: &str) -> SessionManagerLayer<Store>
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_http_only(self, http_only: bool) -> SessionManagerLayer<Store>
pub fn with_http_only(self, http_only: bool) -> SessionManagerLayer<Store>
Configures the "HttpOnly" attribute of the cookie used for the
session.
โ ๏ธ Warning: Cross-site scripting risk
Applications should generally not override the default value of
true. If you do, you are exposing your application to increased risk
of cookie theft via techniques like cross-site scripting.
Examples
use tower_sessions::{MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_service = SessionManagerLayer::new(session_store).with_http_only(true);sourcepub fn with_same_site(self, same_site: SameSite) -> SessionManagerLayer<Store>
pub fn with_same_site(self, same_site: SameSite) -> SessionManagerLayer<Store>
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_expiry(self, expiry: Expiry) -> SessionManagerLayer<Store>
pub fn with_expiry(self, expiry: Expiry) -> SessionManagerLayer<Store>
Configures the "Max-Age" attribute of the cookie used for the session.
Examples
use time::Duration;
use tower_sessions::{Expiry, MemoryStore, SessionManagerLayer};
let session_store = MemoryStore::default();
let session_expiry = Expiry::OnInactivity(Duration::hours(1));
let session_service = SessionManagerLayer::new(session_store).with_expiry(session_expiry);sourcepub fn with_secure(self, secure: bool) -> SessionManagerLayer<Store>
pub fn with_secure(self, secure: bool) -> SessionManagerLayer<Store>
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) -> SessionManagerLayer<Store>
pub fn with_path(self, path: String) -> SessionManagerLayer<Store>
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) -> SessionManagerLayer<Store>
pub fn with_domain(self, domain: String) -> SessionManagerLayer<Store>
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> SessionManagerLayer<Store>where
Store: SessionStore,
impl<Store> SessionManagerLayer<Store>where
Store: SessionStore,
sourcepub fn new(session_store: Store) -> SessionManagerLayer<Store>
pub fn new(session_store: Store) -> SessionManagerLayer<Store>
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 for SessionManagerLayer<Store>where
Store: Clone + SessionStore,
impl<Store> Clone for SessionManagerLayer<Store>where
Store: Clone + SessionStore,
sourceยงfn clone(&self) -> SessionManagerLayer<Store>
fn clone(&self) -> SessionManagerLayer<Store>
1.0.0 ยท sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceยงimpl<Store> Debug for SessionManagerLayer<Store>where
Store: Debug + SessionStore,
impl<Store> Debug for SessionManagerLayer<Store>where
Store: Debug + SessionStore,
sourceยงimpl<S, Store> Layer<S> for SessionManagerLayer<Store>where
Store: SessionStore,
impl<S, Store> Layer<S> for SessionManagerLayer<Store>where
Store: SessionStore,
ยงtype Service = CookieManager<SessionManager<S, Store>>
type Service = CookieManager<SessionManager<S, Store>>
sourceยงfn layer(&self, inner: S) -> <SessionManagerLayer<Store> as Layer<S>>::Service
fn layer(&self, inner: S) -> <SessionManagerLayer<Store> as Layer<S>>::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>
impl<Store> UnwindSafe for SessionManagerLayer<Store>where
Store: RefUnwindSafe,
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
ยงimpl<T> Conv for T
impl<T> Conv for T
ยงimpl<T> FmtForward for T
impl<T> FmtForward for T
ยงfn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.ยงfn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.ยงfn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.ยงfn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.ยงfn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.ยงfn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.ยงfn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.ยงfn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.ยงfn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
ยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
ยงimpl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
ยงfn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
ยงfn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreยงfn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreยงfn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
ยงfn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
ยงfn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.ยงfn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.ยงfn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.ยงimpl<T> Pointable for T
impl<T> Pointable for T
ยงimpl<T> Tap for T
impl<T> Tap for T
ยงfn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreยงfn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreยงfn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreยงfn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreยงfn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreยงfn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreยงfn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.ยงfn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.ยงfn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.ยงfn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.ยงfn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.ยงfn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.ยงfn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.