pub struct A2aRouter { /* private fields */ }axum only.Expand description
Builder for an Axum [Router] that serves all A2A v1.0 protocol methods.
Wraps an existing RequestHandler — all business logic, storage, and
interceptors are inherited. This is a thin HTTP routing layer only.
§REST routes
| Method | Path | A2A Method |
|---|---|---|
POST | /message:send | SendMessage |
POST | /message:stream | SendStreamingMessage |
GET | /tasks | ListTasks |
GET | /tasks/:id | GetTask |
POST | /tasks/:id:cancel | CancelTask |
POST or GET | /tasks/:id:subscribe | SubscribeToTask |
POST | /tasks/:task_id/pushNotificationConfigs | CreateTaskPushNotificationConfig |
GET | /tasks/:task_id/pushNotificationConfigs | ListTaskPushNotificationConfigs |
GET | /tasks/:task_id/pushNotificationConfigs/:id | GetTaskPushNotificationConfig |
DELETE | /tasks/:task_id/pushNotificationConfigs/:id | DeleteTaskPushNotificationConfig |
GET | /extendedAgentCard | GetExtendedAgentCard |
GET | /.well-known/agent-card.json | Agent Card Discovery |
GET | /health | Liveness — constant, checks nothing |
GET | /ready | Readiness — probes the task store |
Implementations§
Source§impl A2aRouter
impl A2aRouter
Sourcepub fn new(handler: Arc<RequestHandler>) -> A2aRouter
pub fn new(handler: Arc<RequestHandler>) -> A2aRouter
Creates a new A2aRouter wrapping the given handler.
Sourcepub const fn with_config(
handler: Arc<RequestHandler>,
config: DispatchConfig,
) -> A2aRouter
pub const fn with_config( handler: Arc<RequestHandler>, config: DispatchConfig, ) -> A2aRouter
Creates a new A2aRouter with custom dispatch configuration.
Sourcepub fn with_websocket(self, websocket: WebSocketDispatcher) -> A2aRouter
Available on crate feature websocket only.
pub fn with_websocket(self, websocket: WebSocketDispatcher) -> A2aRouter
websocket only.Serves the WebSocket binding on this router too (audit B-25, ADR
0055): an HTTP/1.1 GET / with Upgrade: websocket is upgraded and
served as CombinedDispatcher::with_websocket
serves it. axum::serve enables upgrades. Its shutdown does not know
upgraded connections: call websocket_upgrades
before into_router and close the handle in
the application’s own shutdown.
Sourcepub fn websocket_upgrades(&self) -> Option<WebSocketUpgrades>
Available on crate feature websocket only.
pub fn websocket_upgrades(&self) -> Option<WebSocketUpgrades>
websocket only.The upgraded connections’ handle, when with_websocket
set one.
Sourcepub fn into_router(self) -> Router
pub fn into_router(self) -> Router
Builds the Axum [Router] with all A2A REST routes.
The router uses Arc<RequestHandler> as shared state (via Axum’s
State extractor). Returns the configured Router, for an
application that composes it with its own routes and serves it with
axum::serve. To serve it alone, give the A2aRouter itself to
Server, which it is a
Dispatcher for (ADR 0052).
Trait Implementations§
Source§impl Dispatcher for A2aRouter
The axum router as a Dispatcher, so it
runs on Server under a
ServeConfig (audit G-09, ADR 0052): the
header-read and idle timeouts, the connection cap, the loopback Host
check, the production refusal and the shutdown that ends the tasks before
it drains the connections. Under plain axum::serve it had none of them.
impl Dispatcher for A2aRouter
The axum router as a Dispatcher, so it
runs on Server under a
ServeConfig (audit G-09, ADR 0052): the
header-read and idle timeouts, the connection cap, the loopback Host
check, the production refusal and the shutdown that ends the tasks before
it drains the connections. Under plain axum::serve it had none of them.
Source§fn dispatch(
&self,
req: Request<Incoming>,
) -> Pin<Box<dyn Future<Output = Response<BoxBody<Bytes, !>>> + Send + '_>>
fn dispatch( &self, req: Request<Incoming>, ) -> Pin<Box<dyn Future<Output = Response<BoxBody<Bytes, !>>> + Send + '_>>
Calls the router into_router would
return, built once, on the first request.
Source§fn request_handler(&self) -> Option<&Arc<RequestHandler>>
fn request_handler(&self) -> Option<&Arc<RequestHandler>>
The handler, so Server ends its tasks before
it drains and stamps its load (ADR 0046) on every response.
Source§fn protocol_binding(&self) -> Option<&'static str>
fn protocol_binding(&self) -> Option<&'static str>
HTTP+JSON; none when with_websocket
makes it serve two bindings.
Auto Trait Implementations§
impl !Freeze for A2aRouter
impl !RefUnwindSafe for A2aRouter
impl !UnwindSafe for A2aRouter
impl Forget for A2aRouter
impl Move for A2aRouter
impl Send for A2aRouter
impl Sync for A2aRouter
impl Unpin for A2aRouter
impl UnsafeUnpin for A2aRouter
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].