use axum::Router;
use downcast::{downcast_sync, AnySync};
#[cfg(test)]
use mockall::automock;
use rustc_hash::FxHashSet;
use springtime_di::injectable;
use springtime_di::instance_provider::{ComponentInstancePtr, ErrorPtr};
pub type ServerNameSet = FxHashSet<String>;
#[injectable]
#[cfg_attr(test, automock)]
pub trait Controller: AnySync {
fn path(&self) -> Option<String> {
None
}
fn server_names(&self) -> Option<ServerNameSet> {
None
}
fn configure_router(
&self,
router: Router,
self_instance_ptr: ComponentInstancePtr<dyn Controller + Send + Sync>,
) -> Result<Router, ErrorPtr>;
fn create_router(&self) -> Result<Router, ErrorPtr>;
fn post_configure_router(&self, router: Router) -> Result<Router, ErrorPtr>;
}
downcast_sync!(dyn Controller + Send + Sync);