#[macro_export]
macro_rules! use_static_files {
(
$router:path
) => {
for file in crate::compiled::templates::statics::STATICS.iter() {
$router.get(&format!("/{}", file.name), false, |_req| async {
Ok(HttpResponse {
status_code: 200,
headers: HashMap::from([("Content-Type".to_string(), file.mime.to_string())]),
body: if file.mime.type_() == "text" || file.mime.subtype() == "json" {
pluto::http::HttpBody::String(
String::from_utf8(file.content.to_vec()).unwrap(),
)
} else {
file.content.to_owned().into()
},
})
});
}
};
}