load method

  1. @override
Future load(
  1. HttpConnect connect,
  2. String uri, {
  3. bool useCache = true,
})
override

Loads the asset of the given URI to the given response.

  • useCache - whether to use the cache. If true (default), it will check the cache first, and update the cache if ncessary.

Implementation

@override
Future load(HttpConnect connect, String uri, {bool useCache = true}) async {
  String path = uri.substring(1); //uri must start with '/', but path can't
  path = Path.join(rootDir, path);

  final file = File(path);
  if (await file.exists())
    return loadAsset(connect, FileAsset(file), useCache ? cache: null);

  if (await Directory(path).exists())
    return _loadFileAt(connect, uri, path, connect.server.indexNames, 0,
        useCache ? cache: null);

  throw Http404(uri: Uri.tryParse(uri));
}