HandlerBuilder

Struct HandlerBuilder 

Source
pub struct HandlerBuilder<S> { /* private fields */ }
Expand description

HandlerBuilder is a builder for SessionHandler.

Implementations§

Source§

impl<S> HandlerBuilder<S>
where S: SessionStore,

Source

pub fn new(store: S, secret: &[u8]) -> Self

Create new HandlerBuilder

Source

pub fn cookie_path(self, cookie_path: impl Into<String>) -> Self

Sets a cookie path for this session middleware.

The default for this value is “/”.

Source

pub fn session_ttl(self, session_ttl: Option<Duration>) -> Self

Sets a session ttl. This will be used both for the cookie expiry and also for the session-internal expiry.

The default for this value is one day. Set this to None to not set a cookie or session expiry. This is not recommended.

Source

pub fn cookie_name(self, cookie_name: impl Into<String>) -> Self

Sets the name of the cookie that the session is stored with or in.

If you are running multiple tide applications on the same domain, you will need different values for each application. The default value is “salvo.session_id”.

Source

pub fn save_unchanged(self, value: bool) -> Self

Sets the save_unchanged value.

When save_unchanged is enabled, a session will cookie will always be set.

With save_unchanged disabled, the session data must be modified from the Default value in order for it to save. If a session already exists and its data unmodified in the course of a request, the session will only be persisted if save_unchanged is enabled.

Source

pub fn same_site_policy(self, policy: SameSite) -> Self

Sets the same site policy for the session cookie. Defaults to SameSite::Lax. See incrementally better cookies for more information about this setting.

Source

pub fn cookie_domain(self, cookie_domain: impl AsRef<str>) -> Self

Sets the domain of the cookie.

Source

pub fn fallback_keys(self, keys: Vec<impl Into<Key>>) -> Self

Sets fallbacks.

Source

pub fn add_fallback_key(self, key: impl Into<Key>) -> Self

Add fallback secret.

Source

pub fn build(self) -> Result<SessionHandler<S>, Error>

Build SessionHandler

Trait Implementations§

Source§

impl<S> Debug for HandlerBuilder<S>
where S: SessionStore + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for HandlerBuilder<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for HandlerBuilder<S>
where S: RefUnwindSafe,

§

impl<S> Send for HandlerBuilder<S>
where S: Send,

§

impl<S> Sync for HandlerBuilder<S>
where S: Sync,

§

impl<S> Unpin for HandlerBuilder<S>
where S: Unpin,

§

impl<S> UnwindSafe for HandlerBuilder<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more