mod analysis;
mod analysis_cache;
mod architecture;
mod callgraph;
mod capability_matrix;
mod deps;
mod tree;
pub(super) fn handle(
path: &str,
query_str: &str,
method: &str,
_body: &str,
) -> Option<(&'static str, &'static str, String)> {
if path == "/api/graph/enrich" {
return Some(deps::enrich_route(method));
}
deps::get_route(path, query_str)
.or_else(|| callgraph::get_route(path, query_str))
.or_else(|| analysis::get_route(path, query_str))
.or_else(|| architecture::get_route(path, query_str))
.or_else(|| tree::get_route(path, query_str))
}
fn project_basename(abs_root: &str) -> String {
std::path::Path::new(abs_root).file_name().map_or_else(
|| "project".to_string(),
|n| n.to_string_lossy().to_string(),
)
}
fn open_graph(
root: &str,
) -> Result<lean_ctx::core::graph_provider::OpenGraphProvider, (&'static str, &'static str, String)>
{
lean_ctx::core::graph_coordinator::get_or_start_build(root)
.map_err(|progress| building_response(&progress))
}
fn building_response(
progress: &lean_ctx::core::graph_coordinator::GraphBuildProgress,
) -> (&'static str, &'static str, String) {
let json =
serde_json::to_string(progress).unwrap_or_else(|_| "{\"status\":\"building\"}".to_string());
("202 Accepted", "application/json", json)
}