//! Routing utilities

#[allow(unused_imports)]
/// Route definition
#[derive(Debug, Clone)]
pub struct Route {
    /// Route path
    pub path: String,
    /// Route method
    pub method: String,
    /// Handler name
    pub handler: String,
}

/// Router
pub struct Router {
    routes: Vec<Route>,
}

impl Router {
    /// Create a new router
    pub fn new() -> Self {
        Self { routes: Vec::new() }
    }

    /// Add a route
    pub fn add_route(&mut self, route: Route) {
        self.routes.push(route);
    }

    /// Find route by path and method
    pub fn find_route(&self, path: &str, method: &str) -> Option<&Route> {
        self.routes
            .iter()
            .find(|r| r.path == path && r.method == method)
    }
}

impl Default for Router {
    fn default() -> Self {
        Self::new()
    }
}
