start static method

Future<VscHttpDeamon> start({
  1. String? path,
  2. int port = 9001,
  3. Object address = 'http://localhost',
})

Implementation

static Future<VscHttpDeamon> start({
  String? path,
  int port = 9001,
  Object address = 'http://localhost',
}) async {
  path ??= Directory.current.path;

  final pipeline = const Pipeline()
      .addMiddleware(logRequests())
      .addMiddleware(corsHeadersMiddleware(port: port))
      .addHandler(createStaticHandler(path, defaultDocument: 'index.html'));
  final server = await io.serve(pipeline, address, port);
  server.defaultResponseHeaders.remove('X-Content-Type-Options', 'nosniff');
  server.defaultResponseHeaders.remove('x-content-type-options', 'nosniff');
  server.defaultResponseHeaders
      .add('x-frame-options', 'ALLOW-FROM http://localhost:$port');
  return VscHttpDeamon._(server, path);
}