bloom-web-core 0.1.1

Core functionality for the Bloom web framework
use actix_web::web::ServiceConfig;

/// A controller registration entry provided by the #[controller] macro.
///
/// This struct represents a controller that can be registered with the web server.
/// Each controller has a name and a configuration function that sets up its routes.
pub struct Controller {
    pub name: &'static str,
    pub configure: fn(&mut ServiceConfig),
}

inventory::collect!(Controller);

/// Configures all registered controllers with the provided ServiceConfig.
///
/// This function iterates through all controllers registered via the inventory
/// system and calls their configure function to set up their routes.
///
/// # Arguments
/// * `cfg` - The ServiceConfig to configure with controller routes
pub fn configure_all(cfg: &mut ServiceConfig) {
    for c in inventory::iter::<Controller> {
        (c.configure)(cfg);
    }
}