Expand description
Axum framework integration for A2A servers.
Provides A2aRouter, which builds an axum::Router that handles all
A2A v1.0 methods using the existing RequestHandler.
§Quick start
use std::sync::Arc;
use a2a_protocol_server::dispatch::axum_adapter::A2aRouter;
use a2a_protocol_server::RequestHandlerBuilder;
let handler = Arc::new(
RequestHandlerBuilder::new(MyExecutor)
.build()
.expect("build handler"),
);
let app = A2aRouter::new(handler).into_router();
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();§Composability
The returned router can be merged with other Axum routes, middleware, and layers:
ⓘ
let app = axum::Router::new()
.merge(A2aRouter::new(handler).into_router())
.layer(tower_http::cors::CorsLayer::permissive())
.route("/custom", get(custom_handler));