diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index bf6fe449..e60d4a9c 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -11,7 +11,8 @@ mod route; use files::Files; use route::{Route, RouteAffinity}; -use std::path::Path; +use std::path::{Path, PathBuf}; +use std::time::{Instant}; use wws_config::Config; /// Contains all registered routes @@ -36,10 +37,18 @@ impl Routes { let files = Files::new(path, runtime_extensions, ignore_patterns); + let mut route_paths: Vec = Vec::new(); for entry in files.walk() { - routes.push(Route::new(path, entry.into_path(), &prefix, config)); + route_paths.push(entry.into_path()); } + println!("⏳ Loading workers from {} routes...", route_paths.len()); + let start = Instant::now(); + for route_path in route_paths { + routes.push(Route::new(path, route_path, &prefix, config)); + } + println!("✅ Workers loaded in {:?}.", start.elapsed()); + Self { routes, prefix } } diff --git a/src/main.rs b/src/main.rs index bd3651f3..4f748b9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,8 +107,6 @@ async fn main() -> std::io::Result<()> { println!("⚙️ Loading routes from: {}", &args.path.display()); let routes = Routes::new(&args.path, &args.prefix, args.ignore, &config); - - println!("🗺 Detected {} routes:", routes.routes.len()); for route in routes.routes.iter() { println!( " - http://{}:{}{}\n => {}",