Skip to main content

Module serve

Module serve 

Source
Expand description

Server startup helpers.

Reduces the ~25 lines of hyper boilerplate typically needed to start an A2A HTTP server down to a single function call.

§Example

use std::sync::Arc;
use a2a_protocol_server::serve::serve;
use a2a_protocol_server::dispatch::JsonRpcDispatcher;
use a2a_protocol_server::RequestHandlerBuilder;

let handler = Arc::new(
    RequestHandlerBuilder::new(MyExecutor)
        .build()
        .expect("build handler"),
);

let dispatcher = JsonRpcDispatcher::new(handler);
serve("127.0.0.1:3000", dispatcher).await?;

Traits§

Dispatcher
Trait for types that can dispatch HTTP requests to an A2A handler.

Functions§

serve
Starts an HTTP server that dispatches requests using the given dispatcher.
serve_with_addr
Starts an HTTP server and returns the bound SocketAddr.

Type Aliases§

DispatchResponse
The HTTP response type returned by dispatchers.