staticFile method

Route staticFile (String path, dynamic file, { Map<String, String> pathRegEx, int statusCode: 200, String mimeType, String charset: kDefaultCharset, 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(await f.openRead(), mimeType: MimeTypes.ofFile(f)),
      pathRegEx: pathRegEx,
      statusCode: statusCode,
      mimeType: mimeType,
      charset: charset,
      responseProcessor: responseProcessor);