pub mod any;
pub mod default;
pub mod normalize_path;
use crate::app::context::AppContext;
use axum::Router;
use axum_core::extract::FromRef;
#[cfg_attr(test, mockall::automock(type Error = crate::error::Error;))]
pub trait Initializer<S>: Send
where
S: 'static + Send + Sync + Clone,
AppContext: FromRef<S>,
{
type Error: Send + Sync + std::error::Error;
fn name(&self) -> String;
fn enabled(&self, state: &S) -> bool;
fn priority(&self, state: &S) -> i32;
fn after_router(
&self,
#[allow(unused_variables)] state: &S,
router: Router,
) -> Result<Router, Self::Error> {
Ok(router)
}
fn before_middleware(
&self,
#[allow(unused_variables)] state: &S,
router: Router,
) -> Result<Router, Self::Error> {
Ok(router)
}
fn after_middleware(
&self,
#[allow(unused_variables)] state: &S,
router: Router,
) -> Result<Router, Self::Error> {
Ok(router)
}
fn before_serve(
&self,
#[allow(unused_variables)] state: &S,
router: Router,
) -> Result<Router, Self::Error> {
Ok(router)
}
}