checkAll method
Checks all routes to determine if a request matches any defined route.
The routing parameter is a list of FinchRoute objects to check. The parentPath
parameter is used for constructing nested routes.
Returns a Future<bool> indicating whether a matching route was found. If no match is found, it attempts to serve static files from the public directory or returns a 404 error if the file is not found. If an error occurs during file access, a 502 error is returned.
Implementation
Future<bool> checkAll(
List<FinchRoute> routing, {
String parentPath = '',
}) async {
for (var i = 0; i < routing.length; i++) {
var route = routing[i];
if (route.hosts.isNotEmpty && !route.hosts.contains('*')) {
if (!route.hosts.contains(rq.host)) {
continue;
}
}
if (route.ports.isNotEmpty) {
if (!route.ports.contains(rq.port)) {
continue;
}
}
List<String> paths = [route.path, ...route.extraPath];
for (var path in paths) {
path = joinPaths([parentPath, path]);
route.setPathRender(path);
rq.route = route;
var res = await checkOne(route, path);
if (res.found) {
return true;
}
}
}
return false;
}