pub trait RivetModule: Send + Sync {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn configure(&self, _config: &mut dyn Config) -> Result<(), RivetError> { ... }
fn providers(&self) -> Vec<Box<dyn ServiceProvider>> { ... }
fn routes(&self, _routes: &mut Registry) -> Result<(), RivetError> { ... }
fn middleware(&self) -> Vec<Arc<dyn Middleware>> { ... }
}Expand description
Defines one composable unit of rivet behavior.
A module can participate in configuration, service-provider registration, route registration, and middleware registration during the build lifecycle.
Required Methods§
Provided Methods§
Sourcefn configure(&self, _config: &mut dyn Config) -> Result<(), RivetError>
fn configure(&self, _config: &mut dyn Config) -> Result<(), RivetError>
Configure module-specific values before providers/routes are collected.
Sourcefn providers(&self) -> Vec<Box<dyn ServiceProvider>>
fn providers(&self) -> Vec<Box<dyn ServiceProvider>>
Return service providers contributed by this module.
Providers are collected from all modules, then all are registered, then all are booted.
Sourcefn routes(&self, _routes: &mut Registry) -> Result<(), RivetError>
fn routes(&self, _routes: &mut Registry) -> Result<(), RivetError>
Register routes contributed by this module.
Sourcefn middleware(&self) -> Vec<Arc<dyn Middleware>>
fn middleware(&self) -> Vec<Arc<dyn Middleware>>
Return middleware contributed by this module.
Middleware is executed in registration order, then unwinds in reverse order.