pub trait ServerInterceptor:
Send
+ Sync
+ 'static {
// Required methods
fn before<'a>(
&'a self,
ctx: &'a CallContext,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;
fn after<'a>(
&'a self,
ctx: &'a CallContext,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;
// Provided method
fn authenticates(&self) -> bool { ... }
}Expand description
A server-side interceptor for request processing.
Interceptors run before and after the core handler logic. They can be used for logging, authentication, rate-limiting, or other cross-cutting concerns.
§Object safety
This trait is designed to be used behind Arc<dyn ServerInterceptor>.
Required Methods§
Sourcefn before<'a>(
&'a self,
ctx: &'a CallContext,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn before<'a>( &'a self, ctx: &'a CallContext, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Provided Methods§
Sourcefn authenticates(&self) -> bool
fn authenticates(&self) -> bool
Returns true if this interceptor authenticates requests — i.e. its
before hook rejects callers that do not present
valid credentials.
The extended agent card endpoint MUST require authentication (spec
§13.3); the handler uses this marker to verify that at least one
authenticating interceptor guards the chain before serving the card.
The default is false (logging/metrics-style interceptors do not
authenticate); auth interceptors — including custom ones — should
override this to true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".