tryServe method
Implementation
Future<bool> tryServe(HttpRequest req) async {
// Only GET/HEAD are eligible
final method = req.method.toUpperCase();
if (method != 'GET' && method != 'HEAD') return false;
final rel = _sanitize(req.uri.path);
// directory → index.html
final candidate = rel.endsWith('/') ? '${rel}index.html' : rel;
// Try file
final file = File(_join(root.path, candidate));
if (await _serveIfExists(req, file)) return true;
// SPA fallback?
if (spaFallback) {
final index = File(_join(root.path, 'index.html'));
if (await _serveIfExists(req, index)) return true;
}
return false;
}