pub trait ModuleLoader: Send + Sync {
// Required method
fn name(&self) -> &str;
// Provided methods
fn validate_config(
&self,
config: &HashMap<String, String>,
) -> ModuleResult<()> { ... }
fn create_middleware(
&self,
config: &HashMap<String, String>,
) -> ModuleResult<Option<Arc<dyn Handler>>> { ... }
fn create_handler(
&self,
config: &HashMap<String, String>,
) -> ModuleResult<Option<Arc<dyn Handler>>> { ... }
fn on_load(&self) -> ModuleResult<()> { ... }
fn on_unload(&self) -> ModuleResult<()> { ... }
fn on_reload(&self, config: &HashMap<String, String>) -> ModuleResult<()> { ... }
}Expand description
A module loader creates module instances from configuration.
Implement this trait to add custom functionality to gatel. Each loader
is responsible for a named directive (e.g., “my-custom-middleware”) and
creates Module instances when that directive appears in the config.
Required Methods§
Provided Methods§
Sourcefn validate_config(&self, config: &HashMap<String, String>) -> ModuleResult<()>
fn validate_config(&self, config: &HashMap<String, String>) -> ModuleResult<()>
Validate the configuration for this module. Called during config parsing before the server starts. Return Ok(()) if the config is valid, or an error describing the issue.
Sourcefn create_middleware(
&self,
config: &HashMap<String, String>,
) -> ModuleResult<Option<Arc<dyn Handler>>>
fn create_middleware( &self, config: &HashMap<String, String>, ) -> ModuleResult<Option<Arc<dyn Handler>>>
Create a middleware instance from the given configuration. Return None if this module does not provide middleware.
Sourcefn create_handler(
&self,
config: &HashMap<String, String>,
) -> ModuleResult<Option<Arc<dyn Handler>>>
fn create_handler( &self, config: &HashMap<String, String>, ) -> ModuleResult<Option<Arc<dyn Handler>>>
Create a handler instance from the given configuration. Return None if this module does not provide a terminal handler.
Sourcefn on_load(&self) -> ModuleResult<()>
fn on_load(&self) -> ModuleResult<()>
Called once when the module is loaded (server startup).
Sourcefn on_unload(&self) -> ModuleResult<()>
fn on_unload(&self) -> ModuleResult<()>
Called when the server is shutting down.