From ca3c119adb222e17a1565c53eb116b5d5b84f38c Mon Sep 17 00:00:00 2001 From: "Marcel Kapfer (mmk2410)" Date: Tue, 14 Jun 2016 21:47:25 +0200 Subject: [PATCH] Implemented course/{id} API --- lib/server/titamaapi.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/server/titamaapi.dart b/lib/server/titamaapi.dart index 2475543..469737f 100644 --- a/lib/server/titamaapi.dart +++ b/lib/server/titamaapi.dart @@ -40,6 +40,14 @@ class TitamaApi { return _courses; } - + @ApiMethod(path: 'course/{id}') + Course getCourse(int id) { + for (Course course in _courses) { + if (course.id == id) { + return course; + } + } + throw new NotFoundError('Could not find course \'$id\'.'); + } }