use crate::route::hits_from; pub fn module(router: &mut windmark::router::Router) { crate::route::track_mount( router, "/directory", "A map of all publicly available routes on this Gemini capsule", |context| { crate::response::success( &format!( "# Directory\n\nA map of all publicly available routes on this \ Gemini capsule\n\n{}", { let available_routes = crate::route::ROUTES.lock().unwrap(); let mut routes_with_hits: Vec<_> = available_routes .iter() .map(|(r, d)| { let hits = hits_from(r); (hits, format!("=> {} {}", r, d.description)) }) .collect(); routes_with_hits.sort_by(|a, b| b.0.cmp(&a.0)); routes_with_hits .into_iter() .map(|(_, line)| line) .collect::>() .join("\n") } ), &context, ) }, ); }