use axum::{Router, response::Json, routing::get};
use oauth_provider_rs::{GitHubOAuthProvider, OAuthProvider, provider_trait::OAuthProviderConfig};
use remote_mcp_kernel::microkernel::{
GitHubMicrokernelServer, MicrokernelServer, core::CustomRouterConfig,
};
use serde_json::json;
async fn health_check() -> Json<serde_json::Value> {
Json(json!({
"status": "healthy",
"service": "test"
}))
}
async fn api_status() -> Json<serde_json::Value> {
Json(json!({
"api": "working",
"version": "1.0"
}))
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("๐งช Testing custom router functionality...");
let github_config = OAuthProviderConfig::with_oauth_config(
"test_client_id".to_string(),
"test_client_secret".to_string(),
"http://localhost:8080/oauth/callback".to_string(),
"read:user".to_string(),
"github".to_string(),
);
let github_oauth_provider = GitHubOAuthProvider::new_github(github_config);
let oauth_provider = OAuthProvider::new(
github_oauth_provider,
oauth_provider_rs::http_integration::config::OAuthProviderConfig::default(),
);
let health_router = Router::new().route("/health", get(health_check));
let api_router = Router::new().route("/status", get(api_status));
let microkernel: GitHubMicrokernelServer = MicrokernelServer::new()
.with_oauth_provider(oauth_provider)
.with_custom_router(health_router)
.with_custom_router_config(api_router, CustomRouterConfig::with_prefix("/api"));
let router = microkernel.build_router()?;
println!("โ
Router built successfully!");
println!("\n๐ Server would have these endpoints:");
println!(" OAuth:");
println!(" GET /oauth/login");
println!(" GET /oauth/callback");
println!(" POST /oauth/token");
println!(" Custom:");
println!(" GET /health");
println!(" GET /api/status");
println!("\n๐ Custom router functionality is working correctly!");
println!(" The server can be built and all routers are properly attached.");
Ok(())
}