Add warning when no reflector is given
This commit is contained in:
parent
62709c0bbd
commit
ef45d98a45
3 changed files with 20 additions and 13 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.0.0-rc.0
|
||||
* Log a warning when no `reflector` is provided.
|
||||
|
||||
# 2.0.0-alpha.24
|
||||
* Add `AngelEnv` class to `core`.
|
||||
* Deprecate `Angel.isProduction`, in favor of `AngelEnv`.
|
||||
|
|
|
@ -4,18 +4,15 @@ import 'package:angel_framework/http.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
|
||||
main() async {
|
||||
var app = new Angel(
|
||||
// Logging set up/boilerplate
|
||||
Logger.root.onRecord.listen(print);
|
||||
|
||||
// Create our server.
|
||||
var app = Angel(
|
||||
logger: Logger('angel'),
|
||||
reflector: MirrorsReflector(),
|
||||
);
|
||||
|
||||
app.logger = new Logger('angel')
|
||||
..onRecord.listen((rec) {
|
||||
print(rec);
|
||||
if (rec.error != null) print(rec.error);
|
||||
if (rec.stackTrace != null) print(rec.stackTrace);
|
||||
});
|
||||
|
||||
// Index route. Returns JSON.
|
||||
app.get('/', (req, res) => 'Welcome to Angel!');
|
||||
|
||||
|
@ -44,12 +41,12 @@ main() async {
|
|||
|
||||
// Simple fallback to throw a 404 on unknown paths.
|
||||
app.fallback((req, res) {
|
||||
throw new AngelHttpException.notFound(
|
||||
throw AngelHttpException.notFound(
|
||||
message: 'Unknown path: "${req.uri.path}"',
|
||||
);
|
||||
});
|
||||
|
||||
var http = new AngelHttp(app);
|
||||
var http = AngelHttp(app);
|
||||
var server = await http.startServer('127.0.0.1', 3000);
|
||||
var url = 'http://${server.address.address}:${server.port}';
|
||||
print('Listening at $url');
|
||||
|
|
|
@ -3,8 +3,6 @@ library angel_framework.http.server;
|
|||
import 'dart:async';
|
||||
import 'dart:collection' show HashMap;
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:angel_container/angel_container.dart';
|
||||
import 'package:angel_http_exception/angel_http_exception.dart';
|
||||
import 'package:angel_route/angel_route.dart';
|
||||
|
@ -13,7 +11,6 @@ import 'package:http_parser/http_parser.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
import 'env.dart';
|
||||
import 'hooked_service.dart';
|
||||
|
@ -357,6 +354,16 @@ class Angel extends Routable {
|
|||
this.serializer,
|
||||
this.viewGenerator})
|
||||
: super(reflector) {
|
||||
if (reflector == const EmptyReflector()) {
|
||||
var msg =
|
||||
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n'
|
||||
'Features like controllers, constructor dependency injection, and `ioc` require reflection, '
|
||||
'and will not work without it.\n\n'
|
||||
'For more, see the documentation:\n'
|
||||
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
|
||||
logger?.warning(msg);
|
||||
}
|
||||
|
||||
bootstrapContainer();
|
||||
viewGenerator ??= noViewEngineConfigured;
|
||||
serializer ??= json.encode;
|
||||
|
|
Loading…
Reference in a new issue