diff --git a/.idea/runConfigurations/DI_Tests.xml b/.idea/runConfigurations/DI_Tests.xml
index 5c5345d7..002c3572 100644
--- a/.idea/runConfigurations/DI_Tests.xml
+++ b/.idea/runConfigurations/DI_Tests.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2bba0364..d9596f4e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,7 +2,11 @@
+
+
+
+
@@ -23,35 +27,14 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -59,31 +42,48 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
@@ -110,11 +110,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -136,16 +158,18 @@
@@ -156,10 +180,10 @@
DEFINITION_ORDER
-
-
-
-
+
+
+
+
@@ -277,7 +301,7 @@
-
+
@@ -360,6 +384,7 @@
+
1481237183504
@@ -389,21 +414,25 @@
1481389821679
-
+
+ 1483150316137
+
+
+
+ 1483150316138
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
@@ -423,9 +452,12 @@
+
+
+
-
+
@@ -437,29 +469,29 @@
-
+
-
+
-
+
+
-
+
+
-
-
@@ -473,13 +505,22 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -521,6 +562,7 @@
+
@@ -597,6 +639,7 @@
+
@@ -702,72 +745,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -775,13 +753,18 @@
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -796,23 +779,116 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/http/angel_http_exception.dart b/lib/src/http/angel_http_exception.dart
index 072b716e..ebc35257 100644
--- a/lib/src/http/angel_http_exception.dart
+++ b/lib/src/http/angel_http_exception.dart
@@ -57,26 +57,88 @@ class AngelHttpException implements Exception {
/// Throws a 400 Bad Request error, including an optional arrray of (validation?)
/// errors you specify.
+ factory AngelHttpException.badRequest(
+ {String message: '400 Bad Request', List errors: const []}) =>
+ new AngelHttpException(null,
+ message: message, errors: errors, statusCode: 400);
+
+ /// Throws a 401 Not Authenticated error.
+ factory AngelHttpException.notAuthenticated(
+ {String message: '401 Not Authenticated'}) =>
+ new AngelHttpException(null, message: message, statusCode: 401);
+
+ /// Throws a 402 Payment Required error.
+ factory AngelHttpException.paymentRequired(
+ {String message: '402 Payment Required'}) =>
+ new AngelHttpException(null, message: message, statusCode: 402);
+
+ /// Throws a 403 Forbidden error.
+ factory AngelHttpException.forbidden({String message: '403 Forbidden'}) =>
+ new AngelHttpException(null, message: message, statusCode: 403);
+
+ /// Throws a 404 Not Found error.
+ factory AngelHttpException.notFound({String message: '404 Not Found'}) =>
+ new AngelHttpException(null, message: message, statusCode: 404);
+
+ /// Throws a 405 Method Not Allowed error.
+ factory AngelHttpException.methodNotAllowed(
+ {String message: '405 Method Not Allowed'}) =>
+ new AngelHttpException(null, message: message, statusCode: 405);
+
+ /// Throws a 406 Not Acceptable error.
+ factory AngelHttpException.notAcceptable(
+ {String message: '406 Not Acceptable'}) =>
+ new AngelHttpException(null, message: message, statusCode: 406);
+
+ /// Throws a 408 Timeout error.
+ factory AngelHttpException.methodTimeout({String message: '408 Timeout'}) =>
+ new AngelHttpException(null, message: message, statusCode: 408);
+
+ /// Throws a 409 Conflict error.
+ factory AngelHttpException.conflict({String message: '409 Conflict'}) =>
+ new AngelHttpException(null, message: message, statusCode: 409);
+
+ /// Throws a 422 Not Processable error.
+ factory AngelHttpException.notProcessable(
+ {String message: '422 Not Processable'}) =>
+ new AngelHttpException(null, message: message, statusCode: 422);
+
+ /// Throws a 501 Not Implemented error.
+ factory AngelHttpException.notImplemented(
+ {String message: '501 Not Implemented'}) =>
+ new AngelHttpException(null, message: message, statusCode: 501);
+
+ /// Throws a 503 Unavailable error.
+ factory AngelHttpException.unavailable({String message: '503 Unavailable'}) =>
+ new AngelHttpException(null, message: message, statusCode: 503);
+
+ /// Throws a 400 Bad Request error, including an optional arrray of (validation?)
+ /// errors you specify.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.BadRequest(
{String message: '400 Bad Request', List errors: const []}) =>
new AngelHttpException(null,
message: message, errors: errors, statusCode: 400);
/// Throws a 401 Not Authenticated error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.NotAuthenticated(
{String message: '401 Not Authenticated'}) =>
new AngelHttpException(null, message: message, statusCode: 401);
/// Throws a 402 Payment Required error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.PaymentRequired(
{String message: '402 Payment Required'}) =>
new AngelHttpException(null, message: message, statusCode: 402);
/// Throws a 403 Forbidden error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.Forbidden({String message: '403 Forbidden'}) =>
new AngelHttpException(null, message: message, statusCode: 403);
/// Throws a 404 Not Found error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.NotFound({String message: '404 Not Found'}) =>
new AngelHttpException(null, message: message, statusCode: 404);
@@ -86,29 +148,35 @@ class AngelHttpException implements Exception {
new AngelHttpException(null, message: message, statusCode: 405);
/// Throws a 406 Not Acceptable error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.NotAcceptable(
{String message: '406 Not Acceptable'}) =>
new AngelHttpException(null, message: message, statusCode: 406);
/// Throws a 408 Timeout error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.MethodTimeout({String message: '408 Timeout'}) =>
new AngelHttpException(null, message: message, statusCode: 408);
/// Throws a 409 Conflict error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.Conflict({String message: '409 Conflict'}) =>
new AngelHttpException(null, message: message, statusCode: 409);
/// Throws a 422 Not Processable error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.NotProcessable(
{String message: '422 Not Processable'}) =>
new AngelHttpException(null, message: message, statusCode: 422);
/// Throws a 501 Not Implemented error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.NotImplemented(
{String message: '501 Not Implemented'}) =>
new AngelHttpException(null, message: message, statusCode: 501);
/// Throws a 503 Unavailable error.
+ @Deprecated('Use lowercase constructor instead')
factory AngelHttpException.Unavailable({String message: '503 Unavailable'}) =>
new AngelHttpException(null, message: message, statusCode: 503);
}
diff --git a/lib/src/http/controller.dart b/lib/src/http/controller.dart
index d04011b7..9fe76699 100644
--- a/lib/src/http/controller.dart
+++ b/lib/src/http/controller.dart
@@ -90,7 +90,13 @@ class Controller {
return;
}
- routable.addRoute(exposeDecl.method, exposeDecl.path,
+ String name = exposeDecl.as?.isNotEmpty == true
+ ? exposeDecl.as
+ : MirrorSystem.getName(methodName);
+
+ routeMappings[name] = routable.addRoute(
+ exposeDecl.method,
+ exposeDecl.path,
handleContained(reflectedMethod, preInject(reflectedMethod)),
middleware: middleware);
}
diff --git a/lib/src/http/memory_service.dart b/lib/src/http/memory_service.dart
index 7e68599e..852589bf 100644
--- a/lib/src/http/memory_service.dart
+++ b/lib/src/http/memory_service.dart
@@ -36,8 +36,8 @@ class MemoryService extends Service {
MemoryModel found = items[desiredId];
if (found != null) {
return _makeJson(desiredId, found);
- } else throw new AngelHttpException.NotFound();
- } else throw new AngelHttpException.NotFound();
+ } else throw new AngelHttpException.notFound();
+ } else throw new AngelHttpException.notFound();
}
Future create(data, [Map params]) async {
@@ -63,9 +63,9 @@ class MemoryService extends Service {
(data is Map) ? god.deserializeDatum(data, outputType: T) : data;
return _makeJson(desiredId, items[desiredId]);
} catch (e) {
- throw new AngelHttpException.BadRequest(message: 'Invalid data.');
+ throw new AngelHttpException.badRequest(message: 'Invalid data.');
}
- } else throw new AngelHttpException.NotFound();
+ } else throw new AngelHttpException.notFound();
}
Future update(id, data, [Map params]) async {
@@ -76,9 +76,9 @@ class MemoryService extends Service {
(data is Map) ? god.deserializeDatum(data, outputType: T) : data;
return _makeJson(desiredId, items[desiredId]);
} catch (e) {
- throw new AngelHttpException.BadRequest(message: 'Invalid data.');
+ throw new AngelHttpException.badRequest(message: 'Invalid data.');
}
- } else throw new AngelHttpException.NotFound();
+ } else throw new AngelHttpException.notFound();
}
Future remove(id, [Map params]) async {
@@ -87,6 +87,6 @@ class MemoryService extends Service {
MemoryModel item = items[desiredId];
items[desiredId] = null;
return _makeJson(desiredId, item);
- } else throw new AngelHttpException.NotFound();
+ } else throw new AngelHttpException.notFound();
}
}
\ No newline at end of file