diff --git a/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml b/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml
new file mode 100644
index 00000000..732a10e5
--- /dev/null
+++ b/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9a09eed0..8b7d24a9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,13 @@
+
-
+
+
+
+
@@ -38,6 +42,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -49,8 +103,6 @@
- reopen
- REDIRECT
close(
status
createdAt
@@ -79,6 +131,8 @@
handleAn
Tom Fo
handleRequest(
+ transform(
+ grab(
_isClosed
@@ -101,14 +155,11 @@
-
-
-
@@ -130,6 +181,10 @@
+
+
+
+
@@ -164,6 +219,7 @@
+
@@ -190,6 +246,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -246,7 +316,6 @@
-
@@ -275,7 +344,7 @@
-
+
@@ -356,6 +425,12 @@
false
+
+
+
+
+
+
@@ -387,21 +462,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -437,7 +514,9 @@
-
+
+
+
1481237183504
@@ -586,24 +665,31 @@
1498857811360
-
+
+ 1498960583872
+
+
+
+ 1498960583872
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -622,7 +708,7 @@
-
+
@@ -639,21 +725,21 @@
-
-
-
+
+
+
@@ -688,7 +774,8 @@
-
+
+
@@ -795,13 +882,6 @@
-
-
-
-
-
-
-
@@ -809,13 +889,6 @@
-
-
-
-
-
-
-
@@ -830,13 +903,6 @@
-
-
-
-
-
-
-
@@ -907,7 +973,6 @@
-
@@ -932,13 +997,6 @@
-
-
-
-
-
-
-
@@ -981,18 +1039,10 @@
-
-
-
-
-
-
-
-
@@ -1036,7 +1086,7 @@
-
+
@@ -1045,9 +1095,46 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/hooks.dart b/lib/hooks.dart
index 2f4a9ed6..19eca064 100644
--- a/lib/hooks.dart
+++ b/lib/hooks.dart
@@ -33,7 +33,9 @@ AngelConfigurer hookAllServices(callback(Service service)) {
}
/// Transforms `e.data` or `e.result` into JSON-friendly data, i.e. a Map. Runs on Iterables as well.
-HookedServiceEventListener toJson() => transform(god.serializeObject);
+///
+/// The [condition] is optional, and is passed to [transform].
+HookedServiceEventListener toJson([condition]) => transform(god.serializeObject, condition);
/// Mutates `e.data` or `e.result` using the given [transformer].
///
@@ -47,6 +49,7 @@ HookedServiceEventListener toJson() => transform(god.serializeObject);
/// A provided function must take a [HookedServiceEvent] as its only parameter.
HookedServiceEventListener transform(transformer(obj), [condition]) {
Iterable cond = condition is Iterable ? condition : [condition];
+ if (condition == null) cond = [];
_condition(HookedServiceEvent e, condition) async {
if (condition is Function)
diff --git a/lib/src/http/request_context.dart b/lib/src/http/request_context.dart
index e8f291ba..34f31106 100644
--- a/lib/src/http/request_context.dart
+++ b/lib/src/http/request_context.dart
@@ -52,7 +52,7 @@ class RequestContext extends Extensible {
///
/// If you are lazy-parsing request bodies, but have not manually [parse]d this one,
/// then an error will be thrown.
- ///
+ ///
/// **If you are writing a plug-in, use [lazyBody] instead.**
Map get body {
if (_body == null)
@@ -68,7 +68,7 @@ class RequestContext extends Extensible {
///
/// If you are lazy-parsing request bodies, but have not manually [parse]d this one,
/// then an error will be thrown.
- ///
+ ///
/// **If you are writing a plug-in, use [lazyFiles] instead.**
List get files {
if (_body == null)
@@ -81,7 +81,7 @@ class RequestContext extends Extensible {
///
/// If you are lazy-parsing request bodies, but have not manually [parse]d this one,
/// then an error will be thrown.
- ///
+ ///
/// **If you are writing a plug-in, use [lazyOriginalBuffer] instead.**
List get originalBuffer {
if (_body == null)
@@ -100,8 +100,8 @@ class RequestContext extends Extensible {
///
/// If you are lazy-parsing request bodies, but have not manually [parse]d this one,
/// then [uri].query will be returned.
- ///
- /// **If you are writing a plug-in, consider using [lazyQuery] instead.**
+ ///
+ /// **If you are writing a plug-in, consider using [lazyQuery] instead.**
Map get query {
if (_body == null)
return uri.queryParameters;
@@ -167,14 +167,19 @@ class RequestContext extends Extensible {
return injections[key];
else if (properties.containsKey(key))
return properties[key];
- else if (key is Type) {
- try {
- return app.container.make(key);
- } catch (e) {
+ else {
+ var prop = app?.findProperty(key);
+ if (prop != null)
+ return prop;
+ else if (key is Type) {
+ try {
+ return app.container.make(key);
+ } catch (e) {
+ return null;
+ }
+ } else
return null;
- }
- } else
- return null;
+ }
}
/// Shorthand to add to [injections].
diff --git a/lib/src/http/service.dart b/lib/src/http/service.dart
index 97565064..9a27d3f4 100644
--- a/lib/src/http/service.dart
+++ b/lib/src/http/service.dart
@@ -41,7 +41,8 @@ class Service extends Routable {
static const List SPECIAL_QUERY_KEYS = const [
r'$limit',
r'$sort',
- 'page'
+ 'page',
+ 'token'
];
/// The [Angel] app powering this service.
diff --git a/pubspec.yaml b/pubspec.yaml
index ceae67ed..852bea8d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: angel_framework
-version: 1.0.6+1
+version: 1.0.6+2
description: A high-powered HTTP server with DI, routing and more.
author: Tobe O
homepage: https://github.com/angel-dart/angel_framework
diff --git a/test/hooked_test.dart b/test/hooked_test.dart
index 2371498e..d574b2ac 100644
--- a/test/hooked_test.dart
+++ b/test/hooked_test.dart
@@ -117,4 +117,22 @@ main() {
expect(result, isNotEmpty);
expect(result[0], equals({'foo': 'bar'}));
});
+
+ test('contains provider in before and after', () async {
+ var svc = new HookedService(new AnonymousService(index: ([p]) async => []));
+
+ ensureProviderIsPresent(HookedServiceEvent e) {
+ var type = e.isBefore ? 'before' : 'after';
+ print('Params to $type ${e.eventName}: ${e.params}');
+ expect(e.params, isMap);
+ expect(e.params.keys, contains('provider'));
+ expect(e.params['provider'], const isInstanceOf());
+ }
+
+ svc
+ ..beforeAll(ensureProviderIsPresent)
+ ..afterAll(ensureProviderIsPresent);
+
+ await svc.index({'provider': const Providers('testing')});
+ });
}