platform/test/for_browser_tests.dart

31 lines
731 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";
2016-11-28 03:28:41 +00:00
import "package:angel_framework/src/defs.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
});
app.use("/todos", new MemoryService<Todo>());
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}");
channel.sink.add(server.port);
2016-06-25 18:37:49 +00:00
}
class Todo extends MemoryModel {
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
''';