DispatchMiddleware

Trait DispatchMiddleware 

Source
pub trait DispatchMiddleware: Send + Sync {
    // Required methods
    fn before_dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        params: Option<&'life2 Value>,
        session: Option<&'life3 SessionContext>,
    ) -> Pin<Box<dyn Future<Output = Option<McpResult<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn after_dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        result: &'life2 McpResult<Value>,
        session: Option<&'life3 SessionContext>,
    ) -> Pin<Box<dyn Future<Output = McpResult<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Middleware trait for request processing pipeline

Required Methods§

Source

fn before_dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, method: &'life1 str, params: Option<&'life2 Value>, session: Option<&'life3 SessionContext>, ) -> Pin<Box<dyn Future<Output = Option<McpResult<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Process request before routing (return None to continue, Some(Value) to short-circuit)

Source

fn after_dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, method: &'life1 str, result: &'life2 McpResult<Value>, session: Option<&'life3 SessionContext>, ) -> Pin<Box<dyn Future<Output = McpResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Process response after routing

Implementors§