FileHandler constructor
FileHandler({})
Factory constructor that handles path normalization.
The rootPath parameter specifies the root path from which files are served.
The fileSystem parameter specifies the file system to use.
The allowDirectoryListing parameter specifies whether directory listing is allowed.
Implementation
factory FileHandler({
required String rootPath,
file.FileSystem fileSystem = const local.LocalFileSystem(),
bool allowDirectoryListing = false,
}) {
final pathContext = fileSystem.path;
final currentDir = pathContext.normalize(fileSystem.currentDirectory.path);
final normalizedPath = pathContext.normalize(
pathContext.isAbsolute(rootPath)
? rootPath
: pathContext.join(currentDir, rootPath),
);
return FileHandler._(
rootPath: normalizedPath,
fileSystem: fileSystem,
allowDirectoryListing: allowDirectoryListing,
);
}