All fall through
This commit is contained in:
parent
0e5f315773
commit
39d70e74a6
6 changed files with 33 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
# angel_framework
|
# angel_framework
|
||||||
|
|
||||||
![version 1.0.0-dev.24](https://img.shields.io/badge/version-1.0.0--dev.24-red.svg)
|
![version 1.0.0-dev.25](https://img.shields.io/badge/version-1.0.0--dev.25-red.svg)
|
||||||
![build status](https://travis-ci.org/angel-dart/framework.svg)
|
![build status](https://travis-ci.org/angel-dart/framework.svg)
|
||||||
|
|
||||||
Core libraries for the Angel Framework.
|
Core libraries for the Angel Framework.
|
|
@ -5,6 +5,7 @@ import 'dart:io';
|
||||||
import 'dart:math' show Random;
|
import 'dart:math' show Random;
|
||||||
import 'dart:mirrors';
|
import 'dart:mirrors';
|
||||||
import 'package:json_god/json_god.dart' as god;
|
import 'package:json_god/json_god.dart' as god;
|
||||||
|
import 'package:shelf/shelf.dart' as shelf;
|
||||||
import 'angel_base.dart';
|
import 'angel_base.dart';
|
||||||
import 'angel_http_exception.dart';
|
import 'angel_http_exception.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
@ -13,6 +14,7 @@ import 'response_context.dart';
|
||||||
import 'routable.dart';
|
import 'routable.dart';
|
||||||
import 'service.dart';
|
import 'service.dart';
|
||||||
export 'package:container/container.dart';
|
export 'package:container/container.dart';
|
||||||
|
part 'server_shelved.dart';
|
||||||
|
|
||||||
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
|
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
|
||||||
|
|
||||||
|
@ -33,8 +35,8 @@ class Angel extends AngelBase {
|
||||||
var _fatalErrorStream = new StreamController<Map>.broadcast();
|
var _fatalErrorStream = new StreamController<Map>.broadcast();
|
||||||
var _onController = new StreamController<Controller>.broadcast();
|
var _onController = new StreamController<Controller>.broadcast();
|
||||||
final Random _rand = new Random.secure();
|
final Random _rand = new Random.secure();
|
||||||
ServerGenerator _serverGenerator =
|
|
||||||
(address, port) async => await HttpServer.bind(address, port);
|
ServerGenerator _serverGenerator = HttpServer.bind;
|
||||||
|
|
||||||
/// Fired after a request is processed. Always runs.
|
/// Fired after a request is processed. Always runs.
|
||||||
Stream<HttpRequest> get afterProcessed => _afterProcessed.stream;
|
Stream<HttpRequest> get afterProcessed => _afterProcessed.stream;
|
||||||
|
@ -183,12 +185,9 @@ class Angel extends AngelBase {
|
||||||
|
|
||||||
if (requestedUrl.isEmpty) requestedUrl = '/';
|
if (requestedUrl.isEmpty) requestedUrl = '/';
|
||||||
|
|
||||||
final resolved = [];
|
final resolved = resolveAll(requestedUrl, method: request.method);
|
||||||
|
|
||||||
if (requestedUrl == '/') {
|
if (resolved.isNotEmpty) {
|
||||||
resolved.add(root.indexRoute);
|
|
||||||
} else {
|
|
||||||
resolved.addAll(resolveAll(requestedUrl, method: request.method));
|
|
||||||
final route = resolved.first;
|
final route = resolved.first;
|
||||||
req.params.addAll(route?.parseParameters(requestedUrl) ?? {});
|
req.params.addAll(route?.parseParameters(requestedUrl) ?? {});
|
||||||
req.inject(Match, route.match(requestedUrl));
|
req.inject(Match, route.match(requestedUrl));
|
||||||
|
|
19
lib/src/http/server_shelved.dart
Normal file
19
lib/src/http/server_shelved.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
part of angel_framework.http.server;
|
||||||
|
|
||||||
|
|
||||||
|
// Todo: Shelf interop
|
||||||
|
class ShelvedAngel extends Angel {
|
||||||
|
shelf.Pipeline pipeline = new shelf.Pipeline();
|
||||||
|
|
||||||
|
ShelvedAngel({bool debug: false}) : super(debug: debug) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<HttpServer> startServer([InternetAddress address, int port]) async {
|
||||||
|
/* final handler = pipeline.addHandler((shelf.Request req) {
|
||||||
|
// io.handleRequest()
|
||||||
|
});*/
|
||||||
|
|
||||||
|
return await super.startServer(address, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,6 +21,4 @@ getAnnotation(obj, Type T) {
|
||||||
ClassMirror classMirror = reflectClass(obj.runtimeType);
|
ClassMirror classMirror = reflectClass(obj.runtimeType);
|
||||||
return matchingAnnotation(classMirror.metadata, T);
|
return matchingAnnotation(classMirror.metadata, T);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_framework
|
name: angel_framework
|
||||||
version: 1.0.0-dev.24
|
version: 1.0.0-dev.25
|
||||||
description: Core libraries for the Angel framework.
|
description: Core libraries for the Angel framework.
|
||||||
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
|
||||||
|
@ -12,6 +12,7 @@ dependencies:
|
||||||
json_god: ^2.0.0-beta
|
json_god: ^2.0.0-beta
|
||||||
merge_map: ^1.0.0
|
merge_map: ^1.0.0
|
||||||
mime: ^0.9.3
|
mime: ^0.9.3
|
||||||
|
shelf: ^0.6.7
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
http: ^0.11.3
|
http: ^0.11.3
|
||||||
test: ^0.12.13
|
test: ^0.12.13
|
||||||
|
|
|
@ -28,10 +28,8 @@ class TodoController extends Controller {
|
||||||
main() {
|
main() {
|
||||||
Angel app;
|
Angel app;
|
||||||
HttpServer server;
|
HttpServer server;
|
||||||
InternetAddress host = InternetAddress.LOOPBACK_IP_V4;
|
http.Client client = new http.Client();
|
||||||
int port = 3000;
|
String url;
|
||||||
http.Client client;
|
|
||||||
String url = "http://${host.address}:$port";
|
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
app = new Angel();
|
app = new Angel();
|
||||||
|
@ -46,15 +44,14 @@ main() {
|
||||||
print(app.controllers);
|
print(app.controllers);
|
||||||
app.dumpTree();
|
app.dumpTree();
|
||||||
|
|
||||||
server = await app.startServer(host, port);
|
server = await app.startServer();
|
||||||
client = new http.Client();
|
url = 'http://${server.address.address}:${server.port}';
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
await server.close(force: true);
|
await server.close(force: true);
|
||||||
app = null;
|
app = null;
|
||||||
client.close();
|
url = null;
|
||||||
client = null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("middleware", () async {
|
test("middleware", () async {
|
||||||
|
|
Loading…
Reference in a new issue