Permalink
Browse files

Merge pull request #14 from nfrancois/updateDartIO

Update test-app/bin/main.dart with dart:io V2
  • Loading branch information...
2 parents 1872546 + 4837df1 commit 74a7c02d43aa52732ba8f4c85ce41938b7dfdf17 @sethladd sethladd committed Mar 5, 2013
Showing with 13 additions and 16 deletions.
  1. +13 −16 test-app/bin/main.dart
View
@@ -2,21 +2,18 @@ import 'dart:io';
import 'dart:json' as JSON;
main() {
- var server = new HttpServer();
var port = int.parse(Platform.environment['PORT']);
- server.listen('0.0.0.0', port);
- print('Server started on port: ${port}');
-
- server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
-
- var resp = JSON.stringify({
- 'Dart on Heroku': true,
- 'Buildpack URL': 'https://github.com/igrigorik/heroku-buildpack-dart',
- 'Environment': Platform.environment}
- );
-
- response.headers.set(HttpHeaders.CONTENT_TYPE, 'application/json');
- response.outputStream.writeString(resp);
- response.outputStream.close();
- };
+ HttpServer.bind('0.0.0.0', port).then((HttpServer server) {
+ print('Server started on port: ${port}');
+ server.listen((HttpRequest request) {
+ var resp = JSON.stringify({
+ 'Dart on Heroku': true,
+ 'Buildpack URL': 'https://github.com/igrigorik/heroku-buildpack-dart',
+ 'Environment': Platform.environment}
+ );
+ request.response..headers.set(HttpHeaders.CONTENT_TYPE, 'application/json')
+ ..addString(resp)
+ ..close();
+ });
+ });
}

0 comments on commit 74a7c02

Please sign in to comment.