1

i am trying to use VirtualDirectory class and find a great example in web.

import 'dart:io';
import 'package:http_server/http_server.dart';

main() {
    HttpServer.bind('127.0.0.1', 8888).then((HttpServer server) {
        var vd = new VirtualDirectory('./');
        vd.jailRoot = false;
        vd.serve(server);
    });
}

look at call method serve

vd.serve(server);

and the passed parameter, it is from httpserver type. But when i am looking in api docs it expected a httprequest type.

StreamSubscription<HttpRequest> serve(Stream<HttpRequest> requests)
Serve a Stream of HttpRequests, in this VirtualDirectory.

Why i can pass a httpserver instance to serve method instead httpreqeust instance?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

2

See the documentation of HttpServer

The HttpServer is a Stream that provides HttpRequest objects.

Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132