folk-plugin-http 0.2.3

HTTP plugin for Folk — accepts connections via hyper and dispatches to PHP workers
Documentation
pub mod config;
pub mod payload;
pub mod plugin;
pub mod server;

use anyhow::{Context, Result};
use folk_api::{Plugin, PluginFactory, ServerPluginWrapper};
use serde_json::Value;

pub use config::HttpConfig;
pub use plugin::HttpPlugin;

struct HttpPluginFactory;

impl PluginFactory for HttpPluginFactory {
    fn create(&self, config: Value) -> Result<Box<dyn Plugin>> {
        let config: HttpConfig =
            serde_json::from_value(config).context("invalid [http] configuration")?;
        Ok(Box::new(ServerPluginWrapper::new(HttpPlugin::new(config))))
    }
}

pub fn folk_plugin_factory() -> Box<dyn PluginFactory> {
    Box::new(HttpPluginFactory)
}