#[cfg(feature = "auth")]
pub mod auth_routes;
pub mod fallback_routes;
pub mod health_check_route;
#[cfg(feature = "sse")]
pub mod messages_routes;
#[cfg(feature = "sse")]
pub mod sse_routes;
pub mod streamable_http_routes;
use super::HyperServerOptions;
use crate::mcp_http::McpAppState;
use crate::mcp_http::McpHttpHandler;
use axum::{Extension, Router};
use std::sync::Arc;
pub fn app_routes(
state: Arc<McpAppState>,
server_options: &HyperServerOptions,
http_handler: McpHttpHandler,
) -> Router {
let http_handler = Arc::new(http_handler);
let router = {
let mut router = Router::new();
#[cfg(feature = "auth")]
{
router = router.merge(auth_routes::routes(http_handler.clone()));
}
router = router.merge(streamable_http_routes::routes(
server_options.streamable_http_endpoint(),
));
if let Some(health_check_endpoint) = server_options.health_endpoint.as_ref() {
router = router.merge(health_check_route::routes(health_check_endpoint));
}
#[cfg(feature = "sse")]
{
router = router
.merge(sse_routes::routes(
server_options.sse_endpoint(),
server_options.sse_messages_endpoint(),
))
.merge(messages_routes::routes(
server_options.sse_messages_endpoint(),
));
}
router = router.merge(fallback_routes::routes());
router.with_state(state).layer(Extension(http_handler))
};
router
}