From 306549dd53a694fd26536665992dd3ad4cb92079 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Mon, 20 Aug 2018 16:58:37 -0400 Subject: [PATCH] Starts up, but is broken --- .idea/workspace.xml | 378 ++++++++++++------------- lib/src/core/hooked_service.dart | 2 +- lib/src/core/routable.dart | 8 +- lib/src/core/server.dart | 9 +- lib/src/http/http_request_context.dart | 4 +- 5 files changed, 196 insertions(+), 205 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f64ab1bf..0a2c9abe 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,23 +2,7 @@ - - - - - - - - - - - - - - - - @@ -41,11 +25,11 @@ - + - - + + @@ -53,20 +37,47 @@ - - + + - - + + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -74,29 +85,35 @@ - - + + - - + + - - + + - + + + + + + + + + + - - - - - + + @@ -104,41 +121,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -155,9 +139,6 @@ - render - god.serialize - dart:mirrors god.deserialize reflector Angel(M @@ -180,14 +161,16 @@ origina originalBuffer lazyQue - injections singleton( preI ); RequestContext req + req.inject + injections + injecti + debug - !isOpen 'server' FutureOr var body = await getBody(rs); @@ -217,6 +200,7 @@ rawResponse. )); req + req.container C:\Users\thosa\Source\Angel\framework\lib @@ -248,7 +232,6 @@ @@ -415,7 +399,7 @@ - + @@ -1091,7 +1075,7 @@ - @@ -1111,7 +1095,7 @@ - + @@ -1154,8 +1138,6 @@ @@ -1187,13 +1171,6 @@ - - - - - - - @@ -1290,13 +1267,6 @@ - - - - - - - @@ -1355,13 +1325,6 @@ - - - - - - - @@ -1372,16 +1335,6 @@ - - - - - - - - - - @@ -1399,26 +1352,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -1443,13 +1376,6 @@ - - - - - - - @@ -1471,20 +1397,6 @@ - - - - - - - - - - - - - - @@ -1492,13 +1404,6 @@ - - - - - - - @@ -1520,22 +1425,101 @@ - + - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/core/hooked_service.dart b/lib/src/core/hooked_service.dart index f9bfd987..0bca22d0 100644 --- a/lib/src/core/hooked_service.dart +++ b/lib/src/core/hooked_service.dart @@ -1,4 +1,4 @@ -library angel_framework.http; +library angel_framework.core.hooked_service; import 'dart:async'; import '../util.dart'; diff --git a/lib/src/core/routable.dart b/lib/src/core/routable.dart index b34fe06d..0f1f18c2 100644 --- a/lib/src/core/routable.dart +++ b/lib/src/core/routable.dart @@ -94,10 +94,10 @@ class Routable extends Router { /// The [router] may only omitted when called via /// an [Angel] instance. /// - /// Returns either a [Route] or a [Service] (if one was mounted). - use(path, [Router router, String namespace = null]) { + /// Returns a [HookedService] (if one was mounted). + HookedService use(path, [Router router, String namespace = null]) { Router _router = router; - Service service; + HookedService service; // If we need to hook this service, do it here. It has to be first, or // else all routes will point to the old service. @@ -153,6 +153,6 @@ class Routable extends Router { if (_onService.hasListener) _onService.add(service); } - return service ?? mounted; + return service; } } diff --git a/lib/src/core/server.dart b/lib/src/core/server.dart index 115a1c60..8ec22f32 100644 --- a/lib/src/core/server.dart +++ b/lib/src/core/server.dart @@ -14,6 +14,7 @@ import 'package:meta/meta.dart'; import 'package:tuple/tuple.dart'; import '../http/http.dart'; +import 'hooked_service.dart'; import 'request_context.dart'; import 'response_context.dart'; import 'routable.dart'; @@ -361,6 +362,11 @@ class Angel extends Routable { return new Future.sync(() => configurer(this)); } + /// Shorthand for calling `all('*', handler)`. + Route fallback(RequestHandler handler) { + return all('*', handler); + } + /// Mounts the child on this router. If [routable] is `null`, /// then this method will add a handler as a global middleware instead. /// @@ -372,8 +378,7 @@ class Angel extends Routable { /// NOTE: The above will not be properly copied if [path] is /// a [RegExp]. @override - use(path, [Router routable, String namespace = null]) { - if (routable == null) return all('*', path); + HookedService use(path, [Router routable, String namespace = null]) { var head = path.toString().replaceAll(_straySlashes, ''); diff --git a/lib/src/http/http_request_context.dart b/lib/src/http/http_request_context.dart index 2e71dd26..c9f210f2 100644 --- a/lib/src/http/http_request_context.dart +++ b/lib/src/http/http_request_context.dart @@ -93,7 +93,9 @@ class HttpRequestContext extends RequestContext { request.method; ctx.app = app; - ctx._contentType = MediaType.parse(request.headers.contentType.toString()); + ctx._contentType = request.headers.contentType == null + ? null + : MediaType.parse(request.headers.contentType.toString()); ctx._override = override; /*