via/
app.rs

1use crate::middleware::Middleware;
2use crate::router::{Route, Router};
3
4pub struct App<T> {
5    pub(crate) state: T,
6    pub(crate) router: Router<T>,
7}
8
9/// Constructs a new [`App`] with the provided `state` argument.
10///
11pub fn app<T>(state: T) -> App<T> {
12    App {
13        state,
14        router: Router::new(),
15    }
16}
17
18impl<T> App<T> {
19    pub fn at(&mut self, pattern: &'static str) -> Route<T> {
20        self.router.at(pattern)
21    }
22
23    pub fn include(&mut self, middleware: impl Middleware<T> + 'static) -> &mut Self {
24        self.at("/").include(middleware);
25        self
26    }
27}