Skip to main content

RivetModule

Trait RivetModule 

Source
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§

Source

fn name(&self) -> &'static str

Stable module name used for logging and error context.

Provided Methods§

Source

fn configure(&self, _config: &mut dyn Config) -> Result<(), RivetError>

Configure module-specific values before providers/routes are collected.

Source

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.

Source

fn routes(&self, _routes: &mut Registry) -> Result<(), RivetError>

Register routes contributed by this module.

Source

fn middleware(&self) -> Vec<Arc<dyn Middleware>>

Return middleware contributed by this module.

Middleware is executed in registration order, then unwinds in reverse order.

Implementors§