Skip to main content

sofie_http/gate/optional/
group.rs

1use crate::{Area, Routes};
2
3pub trait Groups {
4    /// A record below `path` must hold the ids its path parameters name, or it is not found.
5    fn group(&mut self, path: &str, define: impl FnOnce(&mut Self));
6}
7
8impl<A: Area> Groups for Routes<A> {
9    fn group(&mut self, path: &str, define: impl FnOnce(&mut Self)) {
10        let mut inner = Self::new(self.module);
11        define(&mut inner);
12        for mut route in inner.added {
13            route.path.insert_str(A::PREFIX.len(), path);
14            self.added.push(route);
15        }
16    }
17}