use std::path::Path;
use salvo::Router;
use crate::static_server::{NoRedirectStaticRouter, StaticRouter};
pub(super) fn build_assets_handler(site_root: &Path) -> Option<NoRedirectStaticRouter> {
match StaticRouter::new_with_cacher(site_root) {
Ok(handler) => Some(handler.with_no_redirect()),
Err(e) => {
tracing::warn!(path = ?site_root, error = %e, "SSR dist directory missing; static assets will not be served");
None
}
}
}
pub fn assets_only_router(site_root: &Path) -> Router {
match build_assets_handler(site_root) {
Some(handler) => Router::with_path("{**rest_path}").get(handler),
None => Router::new(),
}
}