diff --git a/lib/src/http/services/memory.dart b/lib/src/http/services/memory.dart index d2135b7b..f94d5555 100644 --- a/lib/src/http/services/memory.dart +++ b/lib/src/http/services/memory.dart @@ -5,8 +5,11 @@ class MemoryService extends Service { God god = new God(); Map items = {}; - Map makeJson(int index, T t) { - return mergeMap([god.serializeToMap(t), {'id': index}]); + makeJson(int index, T t) { + if (T == null || T == Map) + return mergeMap([god.serializeToMap(t), {'id': index}]); + else + return t; } Future index([Map params]) async { @@ -16,7 +19,7 @@ class MemoryService extends Service { .toList(); } - Future read(id, [Map params]) async { + Future read(id, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { T found = items[desiredId]; @@ -26,7 +29,7 @@ class MemoryService extends Service { } else throw new AngelHttpException.NotFound(); } - Future create(data, [Map params]) async { + Future create(data, [Map params]) async { try { items[items.length] = (data is Map) ? god.deserializeFromMap(data, T) : data; @@ -37,7 +40,7 @@ class MemoryService extends Service { } } - Future modify(id, data, [Map params]) async { + Future modify(id, data, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { try { @@ -52,7 +55,7 @@ class MemoryService extends Service { } else throw new AngelHttpException.NotFound(); } - Future update(id, data, [Map params]) async { + Future update(id, data, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { try { @@ -65,7 +68,7 @@ class MemoryService extends Service { } else throw new AngelHttpException.NotFound(); } - Future remove(id, [Map params]) async { + Future remove(id, [Map params]) async { int desiredId = int.parse(id.toString()); if (items.containsKey(desiredId)) { T item = items[desiredId]; diff --git a/pubspec.yaml b/pubspec.yaml index 68701c2f..54d92203 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 0.0.0-dev.16 +version: 0.0.0-dev.17 description: Core libraries for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_framework