platform/packages/hot/example/server.dart
Tobe O 6890bbf53f Add 'packages/hot/' from commit 'ed1422b4fbfdc0bfdd44dd54900f03fb9838ad9b'
git-subtree-dir: packages/hot
git-subtree-mainline: 0aab437ca1
git-subtree-split: ed1422b4fb
2020-02-15 18:28:21 -05:00

33 lines
835 B
Dart

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:logging/logging.dart';
import 'src/foo.dart';
Future<Angel> createServer() async {
var app = Angel()..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 AngelHttpException.notFound());
app.encoders.addAll({
'gzip': gzip.encoder,
'deflate': zlib.encoder,
});
app.logger = Logger.detached('angel')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) {
print(rec.error);
print(rec.stackTrace);
}
});
return app;
}