MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / read_routes

Function read_routes

aiscript-runtime/src/lib.rs:33–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31struct ReloadSignal;
32
33fn read_routes() -> Vec<ast::Route> {
34 let mut routes = Vec::new();
35 for entry in WalkDir::new("routes")
36 .contents_first(true)
37 .into_iter()
38 .filter_entry(|e| {
39 e.file_type().is_file()
40 && e.file_name()
41 .to_str()
42 .map(|s| s.ends_with(".ai"))
43 .unwrap_or(false)
44 })
45 .filter_map(|e| e.ok())
46 {
47 let file_path = entry.path();
48 if let Some(route) = read_single_route(file_path) {
49 routes.push(route);
50 }
51 }
52 routes
53}
54
55fn read_single_route(file_path: &Path) -> Option<ast::Route> {
56 match fs::read_to_string(file_path) {

Callers 1

run_serverFunction · 0.85

Calls 3

read_single_routeFunction · 0.85
to_strMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected