platform/packages/proxy/test/common.dart

25 lines
648 B
Dart
Raw Normal View History

2018-11-02 04:22:32 +00:00
import 'dart:async';
import 'dart:io';
2016-11-23 22:03:06 +00:00
import 'package:angel_framework/angel_framework.dart';
2018-11-02 04:22:32 +00:00
import 'package:angel_framework/http.dart';
2017-09-24 18:49:18 +00:00
import 'package:logging/logging.dart';
2016-11-23 22:03:06 +00:00
2018-11-02 04:22:32 +00:00
Future<HttpServer> startTestServer() {
2019-05-02 23:19:30 +00:00
final app = Angel();
2016-11-23 22:03:06 +00:00
2018-11-02 04:22:32 +00:00
app.get('/hello', (req, res) => res.write('world'));
app.get('/foo/bar', (req, res) => res.write('baz'));
2017-09-24 18:49:18 +00:00
app.post('/body', (RequestContext req, res) async {
2018-12-09 22:39:11 +00:00
var body = await req.parseBody().then((_) => req.bodyAsMap);
2018-11-02 04:22:32 +00:00
app.logger.info('Body: $body');
2017-09-24 18:49:18 +00:00
return body;
2017-04-02 02:06:27 +00:00
});
2019-05-02 23:19:30 +00:00
app.logger = Logger('testApp');
2018-11-02 04:22:32 +00:00
var server = AngelHttp(app);
app.dumpTree();
2017-09-24 18:49:18 +00:00
2018-11-02 04:22:32 +00:00
return server.startServer();
2017-04-02 02:06:27 +00:00
}