codeuchain/core/
middleware.rs1use async_trait::async_trait;
9use crate::core::context::Context;
10use crate::core::link::LegacyLink;
11
12#[async_trait]
16pub trait Middleware: Send + Sync {
17 async fn before(&self, _link: Option<&dyn LegacyLink>, _ctx: &Context) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
19 Ok(())
20 }
21
22 async fn after(&self, _link: Option<&dyn LegacyLink>, _ctx: &Context) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
24 Ok(())
25 }
26
27 async fn on_error(&self, _link: Option<&dyn LegacyLink>, _error: &Box<dyn std::error::Error + Send + Sync>, _ctx: &Context) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
29 Ok(())
30 }
31}