Skip to content
Clone
d6dc02f
15 lines 319 B Rust
use std::future::Future;
use tokio::task_local;
task_local! {
static REQUEST_ID: String;
}
pub async fn with_request_id<F: Future>(request_id: String, future: F) -> F::Output {
REQUEST_ID.scope(request_id, future).await
}
pub fn request_id() -> Option<String> {
REQUEST_ID.try_with(Clone::clone).ok()
}