tower_web/routing/
route_match.rs

1use config::Config;
2use routing::Captures;
3
4use http::Request;
5
6/// Data captured from an HTTP request when it matches a route.
7///
8/// Primarily, this stores the path captures.
9///
10/// This type is not intended to be used directly.
11#[derive(Debug)]
12pub struct RouteMatch<'a> {
13    /// The matched HTTP request head
14    request: &'a Request<()>,
15
16    /// Route captures
17    captures: Captures,
18
19    /// Config
20    config: &'a Config,
21}
22
23impl<'a> RouteMatch<'a> {
24    /// Create a new `RouteMatch`
25    pub(crate) fn new(request: &'a Request<()>, captures: Captures, config: &'a Config) -> Self {
26        RouteMatch {
27            request,
28            captures,
29            config,
30        }
31    }
32
33    pub(crate) fn request(&self) -> &Request<()> {
34        self.request
35    }
36
37    pub(crate) fn captures(&self) -> &Captures {
38        &self.captures
39    }
40
41    pub(crate) fn config(&self) -> &Config {
42        &self.config
43    }
44}