platform/packages/proxy/test/common.dart
Tobe O dd33154af1 Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8'
git-subtree-dir: packages/proxy
git-subtree-mainline: ee512d5ccf
git-subtree-split: daca263062
2020-02-15 18:22:25 -05:00

24 lines
648 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 = Angel();
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().then((_) => req.bodyAsMap);
app.logger.info('Body: $body');
return body;
});
app.logger = Logger('testApp');
var server = AngelHttp(app);
app.dumpTree();
return server.startServer();
}