Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn info(&self) -> PluginInfo;

    // Provided methods
    fn on_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _config: &'life1 Value,
        _head: &'life2 mut Parts,
        _ctx: &'life3 mut HttpContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn on_request_body<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _config: &'life1 Value,
        _body: &'life2 mut Option<Bytes>,
        _ctx: &'life3 mut HttpContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn on_response<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _config: &'life1 Value,
        _head: &'life2 mut Parts,
        _ctx: &'life3 mut HttpContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn on_response_body(
        &self,
        _config: &Value,
        _body: &mut Option<Bytes>,
        _ctx: &mut HttpContext,
    ) -> Result<(), PluginError> { ... }
    fn on_logging<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _: &'life1 Value,
        _: &'life2 mut HttpContext,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}

Required Methods§

Source

fn name(&self) -> &str

插件名称

Source

fn info(&self) -> PluginInfo

插件信息

Provided Methods§

Source

fn on_request<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _config: &'life1 Value, _head: &'life2 mut Parts, _ctx: &'life3 mut HttpContext, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

请求阶段,可改写头部

Source

fn on_request_body<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _config: &'life1 Value, _body: &'life2 mut Option<Bytes>, _ctx: &'life3 mut HttpContext, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

请求体阶段,可改写请求体

Source

fn on_response<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _config: &'life1 Value, _head: &'life2 mut Parts, _ctx: &'life3 mut HttpContext, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

响应阶段,可改写头部

Source

fn on_response_body( &self, _config: &Value, _body: &mut Option<Bytes>, _ctx: &mut HttpContext, ) -> Result<(), PluginError>

响应体阶段,可改写响应体

Source

fn on_logging<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _: &'life1 Value, _: &'life2 mut HttpContext, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Trait Implementations§

Source§

impl TryFrom<PathBuf> for Box<dyn Plugin>

Source§

type Error = PluginError

The type returned in the event of a conversion error.
Source§

fn try_from(value: PathBuf) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for Box<dyn Plugin>

Source§

type Error = PluginError

The type returned in the event of a conversion error.
Source§

fn try_from(from: Vec<u8>) -> Result<Box<dyn Plugin>, Self::Error>

Performs the conversion.

Implementors§