use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct ExternalApp {
pub mount_path: String,
pub strategy: ExternalAppStrategy,
}
#[derive(Debug, Clone)]
pub enum ExternalAppStrategy {
Static {
source_dir: PathBuf,
spa_fallback: bool,
},
Ssr {
upstream: String,
dev_command: Option<String>,
health_check: Option<String>,
strip_prefix: bool,
},
Csr {
source_dir: PathBuf,
dev_upstream: Option<String>,
},
}
impl ExternalApp {
pub fn new(mount_path: impl Into<String>, strategy: ExternalAppStrategy) -> Self {
Self {
mount_path: mount_path.into(),
strategy,
}
}
pub fn static_app(mount_path: impl Into<String>, source_dir: impl Into<PathBuf>) -> Self {
Self::new(
mount_path,
ExternalAppStrategy::Static {
source_dir: source_dir.into(),
spa_fallback: false,
},
)
}
pub fn csr_app(
mount_path: impl Into<String>,
source_dir: impl Into<PathBuf>,
dev_upstream: Option<String>,
) -> Self {
Self::new(
mount_path,
ExternalAppStrategy::Csr {
source_dir: source_dir.into(),
dev_upstream,
},
)
}
pub fn ssr_app(mount_path: impl Into<String>, upstream: String) -> Self {
Self::new(
mount_path,
ExternalAppStrategy::Ssr {
upstream,
dev_command: None,
health_check: None,
strip_prefix: false,
},
)
}
}