staticFile method

Route staticFile (
  1. String path,
  2. dynamic file,
  3. {Map<String, String> pathRegEx,
  4. int statusCode: 200,
  5. String mimeType,
  6. String charset: kDefaultCharset,
  7. ResponseProcessor responseProcessor}

Serves requests at path with content of file

Example: final server = Jaguar(); server.staticFile('/hello', p.join('static', 'hello.txt')); await server.serve();


Route staticFile(String path, file,
    {Map<String, String> pathRegEx,
    int statusCode = 200,
    String mimeType,
    String charset = kDefaultCharset,
    ResponseProcessor responseProcessor}) {
  if (file is String) file = File(file);

  final File f = file;
  return this.get(
      (_) async =>
          StreamResponse(f.openRead(), mimeType: MimeTypes.ofFile(f)),
      pathRegEx: pathRegEx,
      statusCode: statusCode,
      mimeType: mimeType,
      charset: charset,
      responseProcessor: responseProcessor);