didOpen method

Future didOpen ()

Invoked when this server becomes ready receive requests.

This method will invoke RequestSink.willOpen and await for it to finish. Once RequestSink.willOpen completes, the underlying server's HTTP requests will be sent to this instance's sink.

RequestSink.didOpen is invoked after this opening has completed.

Implementation

Future didOpen() async {
  server.serverHeader = "aqueduct/${this.identifier}";

  await sink.willOpen();

  logger.fine("ApplicationServer($identifier).didOpen start listening");
  if (captureStack) {
    server.map((baseReq) => new Request(baseReq)).listen((req) {
      Chain.capture(() {
        sink.receive(req);
      });
    });
  } else {
    server.map((baseReq) => new Request(baseReq)).listen(sink.receive);
  }

  sink.didOpen();
  logger.info("Server aqueduct/$identifier started.");
}