blob: 23be14cb4817d4affa65438a69ece4373d10c9d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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::<Vec<_>>()
.join("\n")
}
),
&context,
)
},
);
}
|