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
37
38
39
40
41
42
43
44
use config::Config;
use routing::Captures;

use http::Request;

/// Data captured from an HTTP request when it matches a route.
///
/// Primarily, this stores the path captures.
///
/// This type is not intended to be used directly.
#[derive(Debug)]
pub struct RouteMatch<'a> {
    /// The matched HTTP request head
    request: &'a Request<()>,

    /// Route captures
    captures: Captures,

    /// Config
    config: &'a Config,
}

impl<'a> RouteMatch<'a> {
    /// Create a new `RouteMatch`
    pub(crate) fn new(request: &'a Request<()>, captures: Captures, config: &'a Config) -> Self {
        RouteMatch {
            request,
            captures,
            config,
        }
    }

    pub(crate) fn request(&self) -> &Request<()> {
        self.request
    }

    pub(crate) fn captures(&self) -> &Captures {
        &self.captures
    }

    pub(crate) fn config(&self) -> &Config {
        &self.config
    }
}