leptos-use/src/utils/header_macro.rs

44 lines
1.3 KiB
Rust
Raw Normal View History

#![allow(unused_macros, unused_imports)]
macro_rules! get_header {
(
$header_name:expr,
$function_name:ident,
$option_name:ident
$(,)?
) => {
if cfg!(feature = "ssr") {
#[cfg(all(
not(feature = "axum"),
not(feature = "actix"),
not(feature = "spin")
))]
{
leptos::logging::warn!(
"If you're using `{}` with SSR but without any of the features `axum`, `actix` or `spin` enabled, you have to provide the option `{}`",
stringify!($function_name),
stringify!($option_name)
);
return None;
}
2024-08-14 03:43:00 +01:00
#[cfg(feature = "actix")]
#[allow(unused_imports)]
use http0_2::{HeaderName, header::*};
#[cfg(any(feature = "axum", feature = "spin"))]
#[allow(unused_imports)]
use http1::{HeaderName, header::*};
#[cfg(any(feature = "axum", feature = "actix", feature = "spin"))]
{
let header_name = $header_name;
crate::utils::header(header_name)
}
} else {
None
}
};
}
pub(crate) use get_header;