simple_custom_router_test/
simple_custom_router_test.rs1use axum::{Router, response::Json, routing::get};
7use oauth_provider_rs::{GitHubOAuthProvider, OAuthProvider, provider_trait::OAuthProviderConfig};
8use remote_mcp_kernel::microkernel::{
9 GitHubMicrokernelServer, MicrokernelServer, core::CustomRouterConfig,
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 = OAuthProviderConfig::with_oauth_config(
35 "test_client_id".to_string(),
36 "test_client_secret".to_string(),
37 "http://localhost:8080/oauth/callback".to_string(),
38 "read:user".to_string(),
39 "github".to_string(),
40 );
41
42 let github_oauth_provider = GitHubOAuthProvider::new_github(github_config);
43 let oauth_provider = OAuthProvider::new(
44 github_oauth_provider,
45 oauth_provider_rs::http_integration::config::OAuthProviderConfig::default(),
46 );
47
48 let health_router = Router::new().route("/health", get(health_check));
50
51 let api_router = Router::new().route("/status", get(api_status));
52
53 let microkernel: GitHubMicrokernelServer = MicrokernelServer::new()
55 .with_oauth_provider(oauth_provider)
56 .with_custom_router(health_router)
57 .with_custom_router_config(api_router, CustomRouterConfig::with_prefix("/api"));
58
59 let router = microkernel.build_router()?;
61 println!("โ
Router built successfully!");
62
63 println!("\n๐ Server would have these endpoints:");
65 println!(" OAuth:");
66 println!(" GET /oauth/login");
67 println!(" GET /oauth/callback");
68 println!(" POST /oauth/token");
69 println!(" Custom:");
70 println!(" GET /health");
71 println!(" GET /api/status");
72
73 println!("\n๐ Custom router functionality is working correctly!");
74 println!(" The server can be built and all routers are properly attached.");
75
76 Ok(())
77}