All fall through

This commit is contained in:
thosakwe 2016-11-24 02:12:53 -05:00
parent 0e5f315773
commit 39d70e74a6
6 changed files with 33 additions and 19 deletions

View file

@ -1,6 +1,6 @@
# 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)
Core libraries for the Angel Framework.

View file

@ -5,6 +5,7 @@ import 'dart:io';
import 'dart:math' show Random;
import 'dart:mirrors';
import 'package:json_god/json_god.dart' as god;
import 'package:shelf/shelf.dart' as shelf;
import 'angel_base.dart';
import 'angel_http_exception.dart';
import 'controller.dart';
@ -13,6 +14,7 @@ import 'response_context.dart';
import 'routable.dart';
import 'service.dart';
export 'package:container/container.dart';
part 'server_shelved.dart';
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
@ -33,8 +35,8 @@ class Angel extends AngelBase {
var _fatalErrorStream = new StreamController<Map>.broadcast();
var _onController = new StreamController<Controller>.broadcast();
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.
Stream<HttpRequest> get afterProcessed => _afterProcessed.stream;
@ -183,12 +185,9 @@ class Angel extends AngelBase {
if (requestedUrl.isEmpty) requestedUrl = '/';
final resolved = [];
final resolved = resolveAll(requestedUrl, method: request.method);
if (requestedUrl == '/') {
resolved.add(root.indexRoute);
} else {
resolved.addAll(resolveAll(requestedUrl, method: request.method));
if (resolved.isNotEmpty) {
final route = resolved.first;
req.params.addAll(route?.parseParameters(requestedUrl) ?? {});
req.inject(Match, route.match(requestedUrl));

View 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);
}
}

View file

@ -21,6 +21,4 @@ getAnnotation(obj, Type T) {
ClassMirror classMirror = reflectClass(obj.runtimeType);
return matchingAnnotation(classMirror.metadata, T);
}
return null;
}

View file

@ -1,5 +1,5 @@
name: angel_framework
version: 1.0.0-dev.24
version: 1.0.0-dev.25
description: Core libraries for the Angel framework.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework
@ -12,6 +12,7 @@ dependencies:
json_god: ^2.0.0-beta
merge_map: ^1.0.0
mime: ^0.9.3
shelf: ^0.6.7
dev_dependencies:
http: ^0.11.3
test: ^0.12.13

View file

@ -28,10 +28,8 @@ class TodoController extends Controller {
main() {
Angel app;
HttpServer server;
InternetAddress host = InternetAddress.LOOPBACK_IP_V4;
int port = 3000;
http.Client client;
String url = "http://${host.address}:$port";
http.Client client = new http.Client();
String url;
setUp(() async {
app = new Angel();
@ -46,15 +44,14 @@ main() {
print(app.controllers);
app.dumpTree();
server = await app.startServer(host, port);
client = new http.Client();
server = await app.startServer();
url = 'http://${server.address.address}:${server.port}';
});
tearDown(() async {
await server.close(force: true);
app = null;
client.close();
client = null;
url = null;
});
test("middleware", () async {