pub struct RequestId {
pub request_id: String,
pub trace_id: String,
}Expand description
Correlation identifiers for one request.
Seeded by CallLogging and readable from a handler with
Call::get. The x-request-id response header
carries the request id back to the client.
use churust_core::{Call, Churust, TestClient};
use churust_logging::{CallLogging, RequestId};
let app = Churust::server()
.install(CallLogging::new())
.routing(|r| {
r.get("/", |c: Call| async move {
c.get::<RequestId>().map(|id| id.request_id).unwrap_or_default()
});
})
.build();
let res = TestClient::new(app).get("/").send().await;
assert!(!res.text().is_empty());
assert_eq!(res.header("x-request-id"), Some(res.text().as_str()));Fields§
§request_id: StringUnique to this request.
trace_id: StringShared by every request in the same distributed trace. Taken from an
inbound W3C traceparent when present.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RequestId
impl RefUnwindSafe for RequestId
impl Send for RequestId
impl Sync for RequestId
impl Unpin for RequestId
impl UnsafeUnpin 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