startServer method

Future<Server> startServer (
  1. [dynamic address,
  2. int port]
)

Starts, and returns the server.

Implementation

Future<Server> startServer([address, int port]) {
  var host = address ?? '127.0.0.1';
  return generateServer(host, port ?? 0).then((server) {
    _server = server;
    return Future.wait(app.startupHooks.map(app.configure)).then((_) {
      app.optimizeForProduction();
      _sub = server.listen((request) {
        var stream = createResponseStreamFromRawRequest(request);
        stream.listen((response) {
          return handleRawRequest(request, response);
        });
      });
      return _server;
    });
  });
}