simple_custom_router_test/
simple_custom_router_test.rs1use axum::{response::Json, routing::get, Router};
7use oauth_provider_rs::{GitHubOAuthConfig, GitHubOAuthProvider, OAuthProvider};
8use remote_mcp_kernel::microkernel::{
9 core::CustomRouterConfig, GitHubMicrokernelServer, MicrokernelServer,
10};
11use serde_json::json;
12
13async fn health_check() -> Json<serde_json::Value> {
15 Json(json!({
16 "status": "healthy",
17 "service": "test"
18 }))
19}
20
21async fn api_status() -> Json<serde_json::Value> {
23 Json(json!({
24 "api": "working",
25 "version": "1.0"
26 }))
27}
28
29#[tokio::main]
30async fn main() -> Result<(), Box<dyn std::error::Error>> {
31 println!("๐งช Testing custom router functionality...");
32
33 let github_config = GitHubOAuthConfig {
35 client_id: "test_client_id".to_string(),
36 client_secret: "test_client_secret".to_string(),
37 redirect_uri: "http://localhost:8080/oauth/callback".to_string(),
38 scope: "read:user".to_string(),
39 provider_name: "github".to_string(),
40 };
41
42 let github_oauth_provider = GitHubOAuthProvider::new_github(github_config);
43 let oauth_provider = OAuthProvider::new(github_oauth_provider);
44
45 let health_router = Router::new()
47 .route("/health", get(health_check));
48
49 let api_router = Router::new()
50 .route("/status", get(api_status));
51
52 let microkernel: GitHubMicrokernelServer = MicrokernelServer::new()
54 .with_oauth_provider(oauth_provider)
55 .with_custom_router(health_router)
56 .with_custom_router_config(
57 api_router,
58 CustomRouterConfig::with_prefix("/api"),
59 );
60
61 let router = microkernel.build_router()?;
63 println!("โ
Router built successfully!");
64
65 println!("\n๐ Server would have these endpoints:");
67 println!(" OAuth:");
68 println!(" GET /oauth/login");
69 println!(" GET /oauth/callback");
70 println!(" POST /oauth/token");
71 println!(" Custom:");
72 println!(" GET /health");
73 println!(" GET /api/status");
74
75 println!("\n๐ Custom router functionality is working correctly!");
76 println!(" The server can be built and all routers are properly attached.");
77
78 Ok(())
79}