2.0.4+1 (configureRoutes)

This commit is contained in:
Tobe O 2019-07-25 22:45:47 -04:00
parent 2f2295ed5a
commit e23fd2369f
5 changed files with 10 additions and 6 deletions

BIN
.CHANGELOG.md.swp Normal file

Binary file not shown.

BIN
.pubspec.yaml.swp Normal file

Binary file not shown.

View file

@ -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<List<int>>` that are now
`Stream<Uint8List>`.

View file

@ -27,7 +27,7 @@ class Controller {
/// Applies routes, DI, and other configuration to an [app].
@mustCallSuper
FutureOr<void> configureServer(Angel app) {
Future<void> 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<String> 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<void> configureRoutes(Routable routable) {}
/// Finds the [Expose] declaration for this class.
Expose findExpose(Reflector reflector) => reflector

View file

@ -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 <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework