use std::collections::HashMap; use tiny_http::Request; use crate::{entities::request::Url, utilities::responses::respond_not_found}; pub struct Router { routes: HashMap, } impl Router { pub fn new() -> Self { let routes = HashMap::new(); Router { routes } } pub async fn route(&self, request: Request) { match self.routes.get(&request.get_url_without_parameters()) { Some(handler) => handler(request), None => respond_not_found(request), } } }