platform/packages/proxy/test/common.dart
2024-10-12 18:45:27 -07:00

24 lines
663 B
Dart

import 'dart:async';
import 'dart:io';
import 'package:protevus_framework/protevus_framework.dart';
import 'package:protevus_framework/http.dart';
import 'package:logging/logging.dart';
Future<HttpServer> startTestServer() {
final app = Protevus();
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 = ProtevusHttp(app);
app.dumpTree();
return server.startServer();
}