2.0.4+1 (configureRoutes)
This commit is contained in:
parent
2f2295ed5a
commit
e23fd2369f
5 changed files with 10 additions and 6 deletions
BIN
.CHANGELOG.md.swp
Normal file
BIN
.CHANGELOG.md.swp
Normal file
Binary file not shown.
BIN
.pubspec.yaml.swp
Normal file
BIN
.pubspec.yaml.swp
Normal file
Binary file not shown.
|
@ -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
|
# 2.0.4
|
||||||
* Prepare for Dart SDK change to `Stream<List<int>>` that are now
|
* Prepare for Dart SDK change to `Stream<List<int>>` that are now
|
||||||
`Stream<Uint8List>`.
|
`Stream<Uint8List>`.
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Controller {
|
||||||
|
|
||||||
/// Applies routes, DI, and other configuration to an [app].
|
/// Applies routes, DI, and other configuration to an [app].
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
FutureOr<void> configureServer(Angel app) {
|
Future<void> configureServer(Angel app) async {
|
||||||
_app = app;
|
_app = app;
|
||||||
|
|
||||||
if (injectSingleton != false) {
|
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;
|
app.controllers[name] = this;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies the routes from this [Controller] to some [router].
|
/// 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
|
// Load global expose decl
|
||||||
var classMirror = reflector.reflectClass(this.runtimeType);
|
var classMirror = reflector.reflectClass(this.runtimeType);
|
||||||
Expose exposeDecl = findExpose(reflector);
|
Expose exposeDecl = findExpose(reflector);
|
||||||
|
@ -62,8 +62,8 @@ class Controller {
|
||||||
..addAll(middleware);
|
..addAll(middleware);
|
||||||
final routeBuilder =
|
final routeBuilder =
|
||||||
_routeBuilder(reflector, instanceMirror, routable, handlers);
|
_routeBuilder(reflector, instanceMirror, routable, handlers);
|
||||||
|
await configureRoutes(routable);
|
||||||
classMirror.declarations.forEach(routeBuilder);
|
classMirror.declarations.forEach(routeBuilder);
|
||||||
configureRoutes(routable);
|
|
||||||
|
|
||||||
// Return the name.
|
// Return the name.
|
||||||
return exposeDecl.as?.isNotEmpty == true ? exposeDecl.as : typeMirror.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].
|
/// 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.
|
/// Finds the [Expose] declaration for this class.
|
||||||
Expose findExpose(Reflector reflector) => reflector
|
Expose findExpose(Reflector reflector) => reflector
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_framework
|
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.
|
description: A high-powered HTTP server with dependency injection, routing and much more.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_framework
|
homepage: https://github.com/angel-dart/angel_framework
|
||||||
|
|
Loading…
Reference in a new issue