swim_core/
route.rs

1use std::sync::Arc;
2
3use crate::view::View;
4
5/// A route is a mapping between a path and a view.
6///
7/// When a request is made to a path, the associated view is called to handle the request.
8#[derive(Debug)]
9pub struct Route {
10    pub path: String,
11    pub view: Arc<dyn View>,
12}
13
14impl Route {
15    /// Creates a new route.
16    pub fn new(path: &str, view: impl View) -> Self {
17        Self {
18            path: path.to_string(),
19            view: Arc::new(view),
20        }
21    }
22}