diff --git a/.CHANGELOG.md.swp b/.CHANGELOG.md.swp new file mode 100644 index 00000000..f26c773c Binary files /dev/null and b/.CHANGELOG.md.swp differ diff --git a/.pubspec.yaml.swp b/.pubspec.yaml.swp new file mode 100644 index 00000000..48abd8ec Binary files /dev/null and b/.pubspec.yaml.swp differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa9ef82..7d885486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.0.4+1 +* Run `Controller.configureRoutes` before mounting `@Expose` routes. +* Make `Controller.configureServer` always return a `Future`. + # 2.0.4 * Prepare for Dart SDK change to `Stream>` that are now `Stream`. diff --git a/lib/src/core/controller.dart b/lib/src/core/controller.dart index 6befde29..b9dd28dc 100644 --- a/lib/src/core/controller.dart +++ b/lib/src/core/controller.dart @@ -27,7 +27,7 @@ class Controller { /// Applies routes, DI, and other configuration to an [app]. @mustCallSuper - FutureOr configureServer(Angel app) { + Future configureServer(Angel app) async { _app = app; if (injectSingleton != false) { @@ -36,13 +36,13 @@ class Controller { } } - var name = applyRoutes(app, app.container.reflector); + var name = await applyRoutes(app, app.container.reflector); app.controllers[name] = this; return null; } /// Applies the routes from this [Controller] to some [router]. - String applyRoutes(Router router, Reflector reflector) { + Future applyRoutes(Router router, Reflector reflector) async { // Load global expose decl var classMirror = reflector.reflectClass(this.runtimeType); Expose exposeDecl = findExpose(reflector); @@ -62,8 +62,8 @@ class Controller { ..addAll(middleware); final routeBuilder = _routeBuilder(reflector, instanceMirror, routable, handlers); + await configureRoutes(routable); classMirror.declarations.forEach(routeBuilder); - configureRoutes(routable); // Return the name. return exposeDecl.as?.isNotEmpty == true ? exposeDecl.as : typeMirror.name; @@ -125,7 +125,7 @@ class Controller { } /// Used to add additional routes to the router from within a [Controller]. - void configureRoutes(Routable routable) {} + FutureOr configureRoutes(Routable routable) {} /// Finds the [Expose] declaration for this class. Expose findExpose(Reflector reflector) => reflector diff --git a/pubspec.yaml b/pubspec.yaml index 6d36a858..b8a159cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 2.0.4 +version: 2.0.4+1 description: A high-powered HTTP server with dependency injection, routing and much more. author: Tobe O homepage: https://github.com/angel-dart/angel_framework