INNER CODE UNIT · Rust

new

vercel-community/rust · crates/vercel_runtime_router/src/lib.rs:189

    pub fn new(file_pattern: &str) -> Self {
        let mut routes = glob(file_pattern)
            .expect("Failed to read glob pattern")
            .filter_map(|e| e.ok())
            .map(|raw_path| {
                let path = raw_path.to_str().unwrap();
                Route::from(path)
            })
            .collect::<Vec<_>>();

        routes.sort();
        Router { routes }
    }

    pub fn call(&self, req_path: &str) -> Option<&Route> {
        // Check if there is an optional catch all route
        if let Some(optional_catch_all) = self.routes.iter().find(|r| {
            let dynamic_optional_catch_all_exp = Regex::new(r"\[{2}\.{3}\S+\]{2}").unwrap();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…