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