#![allow(dead_code)]
pub mod apachebasic;
use crate::httpinner::HttpInner;
pub trait Plugin {
fn name(&self) -> &'static str;
fn run(&self, http_inner: &HttpInner) -> Option<String>;
}
pub struct PluginHandler {
plugins: Vec<Box<dyn Plugin>>,
}
impl PluginHandler {
pub fn new() -> Self {
let mut handler = Self {
plugins: Vec::new(),
};
handler.register_known_plugins();
handler
}
pub fn run(&self, http_inner: &HttpInner) -> Vec<String> {
self.plugins
.iter()
.filter_map(|plugin| {
plugin
.run(http_inner)
.map(|result| format!("{}: {}", plugin.name(), result))
})
.collect()
}
pub fn list(&self) -> Vec<String> {
vec!["apachebasic".to_string()]
}
fn register_known_plugins(&mut self) {
self.plugins.push(Box::new(apachebasic::ApacheBasicPlugin));
}
}