2019-05-01 09:41:26 +00:00
|
|
|
import 'dart:async';
|
2019-02-07 02:57:10 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:io';
|
2021-05-15 13:17:18 +00:00
|
|
|
import 'package:angel3_framework/angel3_framework.dart';
|
2019-02-07 02:57:10 +00:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'src/foo.dart';
|
|
|
|
|
|
|
|
Future<Angel> createServer() async {
|
2019-05-01 09:51:27 +00:00
|
|
|
var app = Angel()..serializer = json.encode;
|
2019-02-07 02:57:10 +00:00
|
|
|
hierarchicalLoggingEnabled = true;
|
|
|
|
|
|
|
|
// Edit this line, and then refresh the page in your browser!
|
|
|
|
app.get('/', (req, res) => {'hello': 'hot world!'});
|
2019-05-01 09:51:27 +00:00
|
|
|
app.get('/foo', (req, res) => Foo(bar: 'baz'));
|
2019-02-07 02:57:10 +00:00
|
|
|
|
2019-05-01 09:51:27 +00:00
|
|
|
app.fallback((req, res) => throw AngelHttpException.notFound());
|
2019-02-07 02:57:10 +00:00
|
|
|
|
|
|
|
app.encoders.addAll({
|
|
|
|
'gzip': gzip.encoder,
|
|
|
|
'deflate': zlib.encoder,
|
|
|
|
});
|
|
|
|
|
2019-05-01 09:51:27 +00:00
|
|
|
app.logger = Logger.detached('angel')
|
2019-02-07 02:57:10 +00:00
|
|
|
..onRecord.listen((rec) {
|
|
|
|
print(rec);
|
|
|
|
if (rec.error != null) {
|
|
|
|
print(rec.error);
|
|
|
|
print(rec.stackTrace);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return app;
|
|
|
|
}
|