pub struct RequestId { /* private fields */ }
Expand description
Add an id to every incoming Request
The ID is just incremented on each request to not have to worry about collisions
Implementations§
source§impl RequestId
impl RequestId
sourcepub fn new(header: impl Into<HeaderType>) -> Self
pub fn new(header: impl Into<HeaderType>) -> Self
Create a new RequestId Middleware
Example
// Import Lib
use afire::{Server, Middleware, extension::RequestId};
// Create Server & RequestId Middleware
let mut server = Server::<()>::new("localhost", 8080);
RequestId::new("X-REQ-ID").attach(&mut server);
// Start Server
server.start().unwrap();
Trait Implementations§
source§impl Middleware for RequestId
impl Middleware for RequestId
source§fn pre(&self, req: &mut Request) -> MiddleResult
fn pre(&self, req: &mut Request) -> MiddleResult
Middleware to run Before Routes
source§fn pre_raw(&self, req: &mut Result<Request>) -> MiddleResult
fn pre_raw(&self, req: &mut Result<Request>) -> MiddleResult
Middleware to run before routes.
Because this is the
raw
version of Middleware::pre
, it is passed a Result
.
The default implementation calls Middleware::pre
if the Result
is Ok
.source§fn post_raw(
&self,
req: Result<Rc<Request>>,
res: &mut Result<Response>
) -> MiddleResult
fn post_raw( &self, req: Result<Rc<Request>>, res: &mut Result<Response> ) -> MiddleResult
Middleware to run after routes.
Because this is the
raw
version of Middleware::post
, it is passed a Result
.
The default implementation calls Middleware::post
if the Result
is Ok
.source§fn post(&self, _req: &Request, _res: &mut Response) -> MiddleResult
fn post(&self, _req: &Request, _res: &mut Response) -> MiddleResult
Middleware to run After Routes
source§fn end_raw(&self, req: &Result<Request>, res: &Result<Response>)
fn end_raw(&self, req: &Result<Request>, res: &Result<Response>)
Middleware to run after the response has been handled.
Because this is the
raw
version of Middleware::end
, it is passed a Result
.
The default implementation calls Middleware::end
if the Result
is Ok
.Auto Trait Implementations§
impl RefUnwindSafe for RequestId
impl Send for RequestId
impl Sync for RequestId
impl Unpin for RequestId
impl UnwindSafe for RequestId
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