pub struct ServerHttpMiddlewareChain { /* private fields */ }Available on non-WebAssembly only.
Expand description
Chain of server HTTP middleware handlers.
Executes middleware in priority order (lowest priority first).
Provides symmetry with client-side HttpMiddlewareChain.
§Examples
use pmcp::server::http_middleware::{ServerHttpMiddlewareChain, ServerHttpLoggingMiddleware};
use std::sync::Arc;
let mut chain = ServerHttpMiddlewareChain::new();
// Add logging middleware
chain.add(Arc::new(ServerHttpLoggingMiddleware::new()));
// Middleware executes in priority orderImplementations§
Source§impl ServerHttpMiddlewareChain
impl ServerHttpMiddlewareChain
Sourcepub fn add(&mut self, middleware: Arc<dyn ServerHttpMiddleware>)
pub fn add(&mut self, middleware: Arc<dyn ServerHttpMiddleware>)
Add middleware to the chain.
Middleware will be sorted by priority (lower priority executes first).
Sourcepub async fn process_request(
&self,
request: &mut ServerHttpRequest,
context: &ServerHttpContext,
) -> Result<()>
pub async fn process_request( &self, request: &mut ServerHttpRequest, context: &ServerHttpContext, ) -> Result<()>
Process an incoming HTTP request through the middleware chain.
Executes all middleware on_request hooks in priority order.
Sourcepub async fn process_response(
&self,
response: &mut ServerHttpResponse,
context: &ServerHttpContext,
) -> Result<()>
pub async fn process_response( &self, response: &mut ServerHttpResponse, context: &ServerHttpContext, ) -> Result<()>
Process an outgoing HTTP response through the middleware chain.
Executes all middleware on_response hooks in priority order.
Sourcepub async fn handle_error(
&self,
error: &Error,
context: &ServerHttpContext,
) -> Result<()>
pub async fn handle_error( &self, error: &Error, context: &ServerHttpContext, ) -> Result<()>
Handle an error through the middleware chain.
Notifies all middleware of the error for logging/metrics.
Trait Implementations§
Source§impl Debug for ServerHttpMiddlewareChain
impl Debug for ServerHttpMiddlewareChain
Auto Trait Implementations§
impl !RefUnwindSafe for ServerHttpMiddlewareChain
impl !UnwindSafe for ServerHttpMiddlewareChain
impl Freeze for ServerHttpMiddlewareChain
impl Send for ServerHttpMiddlewareChain
impl Sync for ServerHttpMiddlewareChain
impl Unpin for ServerHttpMiddlewareChain
impl UnsafeUnpin for ServerHttpMiddlewareChain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more