platform/packages/hot/example/server.dart
2024-10-12 03:35:14 -07:00

33 lines
849 B
Dart

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:logging/logging.dart';
import 'src/foo.dart';
Future<Protevus> createServer() async {
var app = Protevus()..serializer = json.encode;
hierarchicalLoggingEnabled = true;
// Edit this line, and then refresh the page in your browser!
app.get('/', (req, res) => {'hello': 'hot world!'});
app.get('/foo', (req, res) => Foo(bar: 'baz'));
app.fallback((req, res) => throw ProtevusHttpException.notFound());
app.encoders.addAll({
'gzip': gzip.encoder,
'deflate': zlib.encoder,
});
app.logger = Logger.detached('protevus')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) {
print(rec.error);
print(rec.stackTrace);
}
});
return app;
}