pub struct Immortal { /* private fields */ }Expand description
Immortal middleware and routing configuration, as well as the session manager.
Implementations§
Source§impl Immortal
impl Immortal
Sourcepub fn listen<S>(&self, socket_addr: S) -> Result<(), ImmortalError<'_>>where
S: Into<SocketAddr>,
pub fn listen<S>(&self, socket_addr: S) -> Result<(), ImmortalError<'_>>where
S: Into<SocketAddr>,
Listens for incoming connections, with as many threads as the system has available for parallelism
Sourcepub fn listen_with<S>(
&self,
socket_addr: S,
thread_count: usize,
) -> Result<(), ImmortalError<'_>>where
S: Into<SocketAddr>,
pub fn listen_with<S>(
&self,
socket_addr: S,
thread_count: usize,
) -> Result<(), ImmortalError<'_>>where
S: Into<SocketAddr>,
Listens for incoming connections using a specific amount of threads
If threading feature is not present, thread_count will be ignored
Sourcepub fn process_buffer(&mut self, request_buffer: &[u8]) -> Vec<u8> ⓘ
pub fn process_buffer(&mut self, request_buffer: &[u8]) -> Vec<u8> ⓘ
Pass a buffer through the HTTP implementation without listening on a port or dispatching tasks to threads.
Sourcepub fn add_middleware(&mut self, func: Handler)
pub fn add_middleware(&mut self, func: Handler)
Adds middleware that gets executed just before the router.
if a middleware handler produces a redirect, all of the following middleware handlers are skipped and the redirect is yielded, if middleware produces a redirect, the router is bypassed and custom routes do not run.
Sourcepub fn register(&mut self, method: &str, route: &str, func: Handler) -> bool
pub fn register(&mut self, method: &str, route: &str, func: Handler) -> bool
Calls into the router to register a function Returns true if a route was registered
Sourcepub fn unregister(&mut self, method: &str, route: &str) -> bool
pub fn unregister(&mut self, method: &str, route: &str) -> bool
Calls into the router to unregister a function Returns true if a route was unregistered
Sourcepub fn fallback(&mut self, func: Handler)
pub fn fallback(&mut self, func: Handler)
Registers the fallback function for when a request is not caught by the router or for if you want to handle all requests manually
Sourcepub fn set_session_duration(&self, duration: Duration)
pub fn set_session_duration(&self, duration: Duration)
sets the maximum duration that a session may be allowed to persist for regardless of inactivity
Sourcepub fn set_inactive_duration(&self, duration: Duration)
pub fn set_inactive_duration(&self, duration: Duration)
Sets the server-side session inactivity expiry duration
Sourcepub fn set_prune_rate(&self, duration: Duration)
pub fn set_prune_rate(&self, duration: Duration)
Sets the prune rate for sessions, will attempt to prune old sessions every duration
Sourcepub fn disable_sessions(&mut self)
pub fn disable_sessions(&mut self)
Configures sessions to be disabled, clears existing server-side sessions
Sourcepub fn enable_sessions(&mut self)
pub fn enable_sessions(&mut self)
Configures sessions to be enabled
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Immortal
impl !RefUnwindSafe for Immortal
impl Send for Immortal
impl Sync for Immortal
impl Unpin for Immortal
impl !UnwindSafe for Immortal
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more