platform/test/for_browser_tests.dart

31 lines
778 B
Dart
Raw Normal View History

2017-01-20 23:57:42 +00:00
const String SERVER = '''
2016-06-25 18:37:49 +00:00
import 'dart:io';
2016-09-03 12:02:32 +00:00
import "package:angel_framework/angel_framework.dart";
2017-03-29 01:52:19 +00:00
import "package:angel_framework/common.dart";
2017-01-20 23:57:42 +00:00
import 'package:stream_channel/stream_channel.dart';
hybridMain(StreamChannel channel) async {
var app = new Angel();
2016-06-25 18:37:49 +00:00
app.before.add((req, ResponseContext res) {
2017-01-20 23:57:42 +00:00
res.headers["Access-Control-Allow-Origin"] = "*";
return true;
2016-06-25 18:37:49 +00:00
});
2017-03-29 01:52:19 +00:00
app.use("/todos", new TypedService<Todo>(new MapService()));
2016-06-25 18:37:49 +00:00
2017-01-20 23:57:42 +00:00
var server = await app.startServer(InternetAddress.LOOPBACK_IP_V4, 0);
print("Server up; listening at http://localhost:\${server.port}");
2017-03-29 01:52:19 +00:00
channel.sink.add('http://\${server.address.address}:\${server.port}');
2016-06-25 18:37:49 +00:00
}
2017-03-29 01:52:19 +00:00
class Todo extends Model {
2016-06-25 18:37:49 +00:00
String hello;
2017-01-20 23:57:42 +00:00
Todo({int id, this.hello}) {
this.id = id;
}
2016-09-03 12:02:32 +00:00
}
2017-01-20 23:57:42 +00:00
''';