pub struct RequestIdLayer { /* private fields */ }Expand description
Middleware that ensures every request/response pair carries a stable correlation ID.
- If the incoming request already has the header (e.g. set by an upstream gateway, load balancer, or calling service), that exact value is kept and echoed back unchanged — this lets one ID follow a request across multiple services instead of getting a new one at each hop.
- Otherwise, a fresh ID is generated with
generate_request_idand injected into the request before it reaches your handler, so handlers can read it like any other header. - The same value is always set on the response, so the caller can log it too — even if it arrived with no ID and this middleware generated one.
Implementations§
Trait Implementations§
Source§impl Default for RequestIdLayer
impl Default for RequestIdLayer
Source§impl Middleware for RequestIdLayer
impl Middleware for RequestIdLayer
fn handle( &self, request: &Request, connection: &ConnectionInfo, next: &dyn Application, ) -> Result<Response, String>
Auto Trait Implementations§
impl Freeze for RequestIdLayer
impl RefUnwindSafe for RequestIdLayer
impl Send for RequestIdLayer
impl Sync for RequestIdLayer
impl Unpin for RequestIdLayer
impl UnsafeUnpin for RequestIdLayer
impl UnwindSafe for RequestIdLayer
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