pub struct RequestLogger;Expand description
Logs every incoming request via tracing. Add it to the server with
Server::with_middleware(RequestLogger).
ⓘ
use actus::prelude::*;
Server::new(init().await?)
.with_middleware(RequestLogger)
.run(3000).await?;Trait Implementations§
Source§impl Middleware for RequestLogger
impl Middleware for RequestLogger
Source§fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<Outcome, WebError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<Outcome, WebError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before the request is routed. Return
Outcome::Continue to
proceed, Outcome::Respond to short-circuit with a normal response,
or Err(WebError) to short-circuit with an error response. The default
implementation continues.Source§fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 Request,
_response: &'life2 mut ReplyData,
) -> Pin<Box<dyn Future<Output = Result<(), WebError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 Request,
_response: &'life2 mut ReplyData,
) -> Pin<Box<dyn Future<Output = Result<(), WebError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after the handler returns (or after a
before-hook
Outcome::Respond short-circuit), on the way back out. request is
the request the reply is for — so the hook can decide what to do based
on the request’s headers / method / path. Mutate response in place
(including replacing it wholesale, or stamping headers via
ReplyData::add_header);
Err(WebError) swaps the reply for an error response. The default
implementation does nothing. Read moreAuto Trait Implementations§
impl Freeze for RequestLogger
impl RefUnwindSafe for RequestLogger
impl Send for RequestLogger
impl Sync for RequestLogger
impl Unpin for RequestLogger
impl UnsafeUnpin for RequestLogger
impl UnwindSafe for RequestLogger
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