platform/packages/proxy/test/common.dart

25 lines
651 B
Dart
Raw Normal View History

2018-11-02 04:22:32 +00:00
import 'dart:async';
import 'dart:io';
2021-06-10 08:47:05 +00:00
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_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);
2022-04-25 00:54:13 +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
}