diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index b8dfae30..088c8509 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -12,7 +12,7 @@
-
+
@@ -454,7 +454,7 @@
-
+
diff --git a/.idea/runConfigurations/Middleware_via_metadata_in_routing_test_dart.xml b/.idea/runConfigurations/Middleware_via_metadata_in_routing_test_dart.xml
new file mode 100644
index 00000000..41e6ad8d
--- /dev/null
+++ b/.idea/runConfigurations/Middleware_via_metadata_in_routing_test_dart.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/encoding_in_streaming_test_dart.xml b/.idea/runConfigurations/encoding_in_streaming_test_dart.xml
new file mode 100644
index 00000000..f3885511
--- /dev/null
+++ b/.idea/runConfigurations/encoding_in_streaming_test_dart.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/metadata_in_hooked_test_dart.xml b/.idea/runConfigurations/metadata_in_hooked_test_dart.xml
new file mode 100644
index 00000000..618cdc73
--- /dev/null
+++ b/.idea/runConfigurations/metadata_in_hooked_test_dart.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml b/.idea/runConfigurations/tests_in_framework__PRODUCTION_.xml
similarity index 66%
rename from .idea/runConfigurations/All_Tests__PRODUCTION_2.xml
rename to .idea/runConfigurations/tests_in_framework__PRODUCTION_.xml
index 27a10c9c..263eac1e 100644
--- a/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml
+++ b/.idea/runConfigurations/tests_in_framework__PRODUCTION_.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7de0fedd..ecb94876 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,14 +2,27 @@
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -32,83 +45,11 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -116,25 +57,43 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
@@ -152,28 +111,6 @@
- parse
- io
- io.
- lazyP
- storeO
- origina
- originalBuffer
- lazyQue
- singleton(
- preI
- );
- RequestContext req
- req.inject
- injections
- injecti
- debug
- handle(
- lock
- add(
- close(
- end()
- stop
sto
sopw
stopw
@@ -181,7 +118,29 @@
handleRe
get container
Parameter
+ log
mirrors
+ dart:mirror
+ dart:io
+ _Par
+ waterfall
+ wtf
+ errorHan
+ nested
+ _parent =
+ headers['content
+ skip
+ Provi
+ contentTy
+ abc
+ /chained
+ flatten
+ sendRe
+ enableB
+ Hooks
+ Middleware
+ /meta
+ complet
FutureOr
@@ -237,13 +196,11 @@
@@ -307,7 +266,7 @@
-
+
@@ -321,8 +280,6 @@
-
-
@@ -330,11 +287,6 @@
-
-
-
-
-
@@ -346,13 +298,6 @@
-
-
-
-
-
-
-
@@ -360,11 +305,6 @@
-
-
-
-
-
@@ -374,6 +314,8 @@
+
+
@@ -418,7 +360,7 @@
-
+
@@ -573,7 +515,8 @@
-
+
+
@@ -609,17 +552,14 @@
-
+
+
+
-
-
-
-
-
@@ -718,21 +658,9 @@
-
-
-
- 1534692805087
-
-
-
- 1534692805087
-
-
- 1534693249779
-
-
-
- 1534693249779
+
+
+
1534693360366
@@ -1063,43 +991,57 @@
1534819472503
-
+
+ 1534861361523
+
+
+
+ 1534861361524
+
+
+ 1534861733989
+
+
+
+ 1534861733990
+
+
-
-
+
+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
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 26d2c047..362f4082 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,6 @@
* Changed view engine to use `Map`.
* Remove dependency on `package:json_god` by default.
* Remove dependency on `package:dart2_constant`.
-* Remove `contentType` argument in `ResponseContext.serialize`.
* Moved `lib/hooks.dart` into `package:angel_hooks`.
* Moved `TypedService` into `package:angel_typed_service`.
* Completely removed the `AngelBase` class.
@@ -47,8 +46,6 @@ type-safe manner.
* Removed `RequestContext.properties`.
* Removed the defunct `debug` property where it still existed.
* `Routable.use` now only accepts a `Service`.
-* The above change removes the concept of "nested apps," which are messy to maintain, and
-not very elegant.
* Removed `Angel.createZoneForRequest`.
* Removed `Angel.defaultZoneCreator`.
* Added all flags to the `Angel` constructor, ex. `Angel.eagerParseBodies`.
@@ -64,4 +61,9 @@ as in many cases it is unnecessary and slows down response time.
* Removed the now-obsolete `ResponseContext.releaseCorrespondingRequest`.
* `preInject` now takes a `Reflector` as its second argument.
* `Angel.reflector` defaults to `const EmptyReflector()`, disabling
-reflection out-of-the-box.
\ No newline at end of file
+reflection out-of-the-box.
+* Removed `Angel.injectEncoders`.
+* Added `Providers.toJson`.
+* Moved `Providers.graphql` to `Providers.graphQL`.
+* `Angel.optimizeForProduction` no longer calls `preInject`,
+as it does not need to.
\ No newline at end of file
diff --git a/README.md b/README.md
index a287997c..9c4cec80 100644
--- a/README.md
+++ b/README.md
@@ -9,38 +9,53 @@ This is the core of the [Angel](https://github.com/angel-dart/angel) framework.
To build real-world applications, please see the [homepage](https://angel-dart.github.io).
```dart
+import 'package:angel_container/mirrors.dart';
import 'package:angel_framework/angel_framework.dart';
main() async {
- var app = new Angel(reflector: MirrorsReflector());
+ var app = new Angel(reflector: MirrorsReflector());
- // Index route. Returns JSON.
- app.get('/', () => 'Welcome to Angel!');
-
- // Accepts a URL like /greet/foo or /greet/bob.
- app.get('/greet/:name', (String name) => 'Hello, $name!');
-
- // Pattern matching - only call this handler if the query value of `name` equals 'emoji'.
- app.get('/greet', (@Query('name', match: 'emoji') String name) => '😇🔥🔥🔥');
-
- // Handle any other query value of `name`.
- app.get('/greet', (@Query('name') String name) => 'Hello, $name!');
-
- // Simple fallback to throw a 404 on unknown paths.
- app.use((RequestContext req) async {
- throw new AngelHttpException.notFound(
- message: 'Unknown path: "${req.uri.path}"',
+ // Index route. Returns JSON.
+ app.get('/', (req, res) => res.write('Welcome to Angel!'));
+
+ // Accepts a URL like /greet/foo or /greet/bob.
+ app.get(
+ '/greet/:name',
+ (req, res) {
+ var name = req.params['name'];
+ res
+ ..write('Hello, $name!')
+ ..close();
+ },
);
- });
+
+ // Pattern matching - only call this handler if the query value of `name` equals 'emoji'.
+ app.get(
+ '/greet',
+ ioc((@Query('name', match: 'emoji') String name) => '😇🔥🔥🔥'),
+ );
+
+ // Handle any other query value of `name`.
+ app.get(
+ '/greet',
+ ioc((@Query('name') String name) => 'Hello, $name!'),
+ );
+
+ // Simple fallback to throw a 404 on unknown paths.
+ app.fallback((req, res) {
+ throw new AngelHttpException.notFound(
+ message: 'Unknown path: "${req.uri.path}"',
+ );
+ });
- var http = new AngelHttp(app);
- var server = await http.startServer('127.0.0.1', 3000);
- var url = 'http://${server.address.address}:${server.port}';
- print('Listening at $url');
- print('Visit these pages to see Angel in action:');
- print('* $url/greet/bob');
- print('* $url/greet/?name=emoji');
- print('* $url/greet/?name=jack');
- print('* $url/nonexistent_page');
+ var http = new AngelHttp(app);
+ var server = await http.startServer('127.0.0.1', 3000);
+ var url = 'http://${server.address.address}:${server.port}';
+ print('Listening at $url');
+ print('Visit these pages to see Angel in action:');
+ print('* $url/greet/bob');
+ print('* $url/greet/?name=emoji');
+ print('* $url/greet/?name=jack');
+ print('* $url/nonexistent_page');
}
```
diff --git a/example/handle_error.dart b/example/handle_error.dart
index 1fa5d1bb..2e7fab11 100644
--- a/example/handle_error.dart
+++ b/example/handle_error.dart
@@ -9,7 +9,8 @@ main() async {
..logger = (new Logger('angel')..onRecord.listen(print))
..encoders.addAll({'gzip': gzip.encoder});
- app.fallback((req, res) => new Future.error('Throwing just because I feel like!'));
+ app.fallback(
+ (req, res) => new Future.error('Throwing just because I feel like!'));
var http = new AngelHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
diff --git a/lib/src/core/hooked_service.dart b/lib/src/core/hooked_service.dart
index 7ef14e78..d9c6a147 100644
--- a/lib/src/core/hooked_service.dart
+++ b/lib/src/core/hooked_service.dart
@@ -121,13 +121,14 @@ class HookedService extends Service {
applyListeners(inner.remove, afterRemoved, true);
}
- List get bootstrappers => new List.from(super.bootstrappers)
- ..add((RequestContext req, ResponseContext res) {
- req.serviceParams
- ..['__requestctx'] = req
- ..['__responsectx'] = res;
- return true;
- });
+ List get bootstrappers =>
+ new List.from(super.bootstrappers)
+ ..add((RequestContext req, ResponseContext res) {
+ req.serviceParams
+ ..['__requestctx'] = req
+ ..['__responsectx'] = res;
+ return true;
+ });
void addRoutes([Service s]) {
super.addRoutes(s ?? inner);
diff --git a/lib/src/core/response_context.dart b/lib/src/core/response_context.dart
index 214637b7..aa821151 100644
--- a/lib/src/core/response_context.dart
+++ b/lib/src/core/response_context.dart
@@ -103,7 +103,7 @@ abstract class ResponseContext
headers["Content-Disposition"] =
'attachment; filename="${filename ?? file.path}"';
- headers['content-type'] = lookupMimeType(file.path);
+ contentType = MediaType.parse(lookupMimeType(file.path));
headers['content-length'] = file.lengthSync().toString();
if (!isBuffered) {
@@ -150,7 +150,7 @@ abstract class ResponseContext
new Map.from(renderParams)
..addAll(data ?? {}))).then((content) {
write(content);
- headers['content-type'] = 'text/html';
+ contentType = new MediaType('text', 'html');
close();
});
}
@@ -241,8 +241,11 @@ abstract class ResponseContext
throw new Exception(
"Controller '${split[0]}' does not contain any action named '${split[1]}'");
- final head =
- controller.findExpose(app.container.reflector).path.toString().replaceAll(_straySlashes, '');
+ final head = controller
+ .findExpose(app.container.reflector)
+ .path
+ .toString()
+ .replaceAll(_straySlashes, '');
final tail = matched
.makeUri(params.keys.fold