staticFile method
Serves requests at path
with content of file
Example: final server = Jaguar(); server.staticFile('/hello', p.join('static', 'hello.txt')); await server.serve();
Implementation
Route staticFile(String path, file,
{Map<String, String>? pathRegEx,
int statusCode = 200,
String? mimeType,
String? charset = kDefaultCharset,
ResponseProcessor? responseProcessor,
Iterable<String? Function(File)>? mimeTypeDetectors}) {
if (file is String) file = File(file);
final File f = file;
return this.get(
path,
(_) async => StreamResponse(
body: f.openRead(),
mimeType: MimeTypes.ofFile(f, detectors: mimeTypeDetectors)),
pathRegEx: pathRegEx,
statusCode: statusCode,
mimeType: mimeType,
charset: charset,
responseProcessor: responseProcessor);
}