ferro_rs/http/request_context.rs
1//! Task-local request context accessible from any handler without a `Request` parameter.
2
3tokio::task_local! {
4 pub(crate) static REQUEST_HOST: String;
5}
6
7/// Return the `Host` header value (scheme-less, port stripped) for the current request.
8///
9/// Available inside any handler executed by the ferro server. Returns `None` outside
10/// of a request context (e.g. during tests or background jobs).
11pub fn request_host() -> Option<String> {
12 REQUEST_HOST.try_with(|h| h.clone()).ok()
13}