call method
Implementation
void call(Request req, Response res, @Next() next) async {
final isToPublicFiles = req.method == 'GET' &&
_getNameFromPath(path) == _getNameFromPath(req.path);
if (isToPublicFiles) {
final file = File(req.path.replaceFirst('/', ''));
if (!await file.exists()) {
return res.notFound();
}
res.response.headers.contentType =
getContentTypeForFile(res.response.headers.contentType, file);
await res.response.addStream(file.openRead());
} else {
await next();
}
}