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
use indexmap::IndexMap;

#[derive(Debug, Clone)]
pub struct HandlerMatch {
    pub path: Vec<String>,
    pub name: String,
    pub captures: IndexMap<String, String>,
}

impl HandlerMatch {

    pub fn path_without_last(&self) -> Vec<&str> {
        self.path.iter().rev().skip(1).rev().map(AsRef::as_ref).collect()
    }

    pub fn group_name(&self) -> &str {
        self.path().last().unwrap()
    }

    pub fn path(&self) -> Vec<&str> {
        self.path.iter().map(AsRef::as_ref).collect()
    }

    pub fn handler_name(&self) -> &str {
        self.name.as_str()
    }

    pub fn captures(&self) -> &IndexMap<String, String> {
        &self.captures
    }
}