aboutsummaryrefslogtreecommitdiff
path: root/src/modules/random.rs
blob: 4125be1c5163d3a303e21f3172a75557e2c36a14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use rand::prelude::SliceRandom;

pub fn module(router: &mut windmark::router::Router) {
  crate::route::track_mount(
    router,
    "/random",
    "Get redirected to a random route",
    windmark::temporary_redirect!(
      (*crate::route::ROUTES.lock().unwrap())
        .iter()
        .collect::<Vec<_>>()
        .choose(&mut rand::thread_rng())
        .unwrap()
        .0
    ),
  );
}