platform/packages/proxy/test/common.dart

25 lines
663 B
Dart
Raw Permalink Normal View History

2018-11-02 04:22:32 +00:00
import 'dart:async';
import 'dart:io';
import 'package:protevus_framework/protevus_framework.dart';
import 'package:protevus_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() {
final app = Protevus();
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');
var server = ProtevusHttp(app);
2018-11-02 04:22:32 +00:00
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
}