rust_mcp_sdk/hyper_servers/
routes.rs

1pub mod fallback_routes;
2pub mod messages_routes;
3pub mod sse_routes;
4
5use super::{app_state::AppState, HyperServerOptions};
6use axum::Router;
7use std::sync::Arc;
8
9/// Constructs the Axum router with all application routes
10///
11/// Combines routes for Server-Sent Events, message handling, and fallback routes,
12/// attaching the shared application state to the router.
13///
14/// # Arguments
15/// * `state` - Shared application state wrapped in an Arc
16/// * `server_options` - Reference to the HyperServer configuration options
17///
18/// # Returns
19/// * `Router` - An Axum router configured with all application routes and state
20pub fn app_routes(state: Arc<AppState>, server_options: &HyperServerOptions) -> Router {
21    Router::new()
22        .merge(sse_routes::routes(
23            state.clone(),
24            server_options.sse_endpoint(),
25        ))
26        .merge(messages_routes::routes(state.clone()))
27        .with_state(state)
28        .merge(fallback_routes::routes())
29}