platform/test/common.dart
2018-11-02 05:22:32 +01:00

26 lines
702 B
Dart

import 'dart:async';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:logging/logging.dart';
Future<HttpServer> startTestServer() {
final app = new Angel()
..eagerParseRequestBodies = false
..keepRawRequestBuffers = true;
app.get('/hello', (req, res) => res.write('world'));
app.get('/foo/bar', (req, res) => res.write('baz'));
app.post('/body', (RequestContext req, res) async {
var body = await req.parseBody();
app.logger.info('Body: $body');
return body;
});
app.logger = new Logger('testApp');
var server = AngelHttp(app);
app.dumpTree();
return server.startServer();
}