Deprecated ServerGenerator

This commit is contained in:
Tobe O 2018-02-06 23:17:40 -05:00
parent 9e21634764
commit 116824e7c5
5 changed files with 94 additions and 73 deletions

View file

@ -3,6 +3,9 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment=""> <list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/angel_http.dart" afterPath="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/http.dart" afterPath="$PROJECT_DIR$/lib/src/http/http.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/server.dart" afterPath="$PROJECT_DIR$/lib/src/http/server.dart" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/server.dart" afterPath="$PROJECT_DIR$/lib/src/http/server.dart" />
</list> </list>
<ignored path="$PROJECT_DIR$/.tmp/" /> <ignored path="$PROJECT_DIR$/.tmp/" />
@ -25,16 +28,26 @@
<favorites_list name="framework" /> <favorites_list name="framework" />
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<splitter split-orientation="horizontal" split-proportion="0.7132018"> <splitter split-orientation="horizontal" split-proportion="0.50455236">
<split-first> <split-first>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="375"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
<file leaf-file-name="server.dart" pinned="false" current-in-tab="true"> <file leaf-file-name="server.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="168"> <state relative-caret-position="135">
<caret line="44" column="29" lean-forward="true" selection-start-line="44" selection-start-column="29" selection-end-line="44" selection-end-column="29" /> <caret line="9" column="19" lean-forward="false" selection-start-line="9" selection-start-column="19" selection-end-line="9" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="metric_server.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/stats/metric_server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="65" column="61" lean-forward="false" selection-start-line="65" selection-start-column="61" selection-end-line="65" selection-end-column="61" />
<folding> <folding>
<element signature="e#38#58#0" expanded="true" /> <marker date="1512571506000" expanded="true" signature="675:868" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -47,12 +60,10 @@
<file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="true"> <file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="273"> <state relative-caret-position="279">
<caret line="41" column="0" lean-forward="true" selection-start-line="41" selection-start-column="0" selection-end-line="41" selection-end-column="0" /> <caret line="27" column="64" lean-forward="false" selection-start-line="27" selection-start-column="64" selection-end-line="27" selection-end-column="64" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
<element signature="e#3455#3460#0" expanded="false" />
<element signature="e#3763#3788#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -183,7 +194,6 @@
<option value="$PROJECT_DIR$/lib/src/http/injection.dart" /> <option value="$PROJECT_DIR$/lib/src/http/injection.dart" />
<option value="$PROJECT_DIR$/test/parameter_meta_test.dart" /> <option value="$PROJECT_DIR$/test/parameter_meta_test.dart" />
<option value="$PROJECT_DIR$/test/pattern_matcher_test.dart" /> <option value="$PROJECT_DIR$/test/pattern_matcher_test.dart" />
<option value="$PROJECT_DIR$/lib/src/http/http.dart" />
<option value="$PROJECT_DIR$/lib/src/http/angel_base.dart" /> <option value="$PROJECT_DIR$/lib/src/http/angel_base.dart" />
<option value="$PROJECT_DIR$/lib/src/http/hooked_service.dart" /> <option value="$PROJECT_DIR$/lib/src/http/hooked_service.dart" />
<option value="$PROJECT_DIR$/lib/metrics.dart" /> <option value="$PROJECT_DIR$/lib/metrics.dart" />
@ -205,9 +215,10 @@
<option value="$PROJECT_DIR$/lib/src/http/service.dart" /> <option value="$PROJECT_DIR$/lib/src/http/service.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" /> <option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" /> <option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/example/json.dart" /> <option value="$PROJECT_DIR$/example/json.dart" />
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" /> <option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/lib/src/http/http.dart" />
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" /> <option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" /> <option value="$PROJECT_DIR$/lib/src/http/server.dart" />
</list> </list>
@ -617,14 +628,7 @@
<workItem from="1513103483207" duration="18000" /> <workItem from="1513103483207" duration="18000" />
<workItem from="1513103506825" duration="139000" /> <workItem from="1513103506825" duration="139000" />
<workItem from="1517332581856" duration="858000" /> <workItem from="1517332581856" duration="858000" />
<workItem from="1517973177718" duration="3606000" /> <workItem from="1517973177718" duration="3858000" />
</task>
<task id="LOCAL-00009" summary="+1">
<created>1493088262571</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1493088262571</updated>
</task> </task>
<task id="LOCAL-00010" summary="+2"> <task id="LOCAL-00010" summary="+2">
<created>1493090378709</created> <created>1493090378709</created>
@ -962,7 +966,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1517976712783</updated> <updated>1517976712783</updated>
</task> </task>
<option name="localTasksCounter" value="58" /> <task id="LOCAL-00058" summary="Deprecated createZoneForRequest">
<created>1517976806435</created>
<option name="number" value="00058" />
<option name="presentableId" value="LOCAL-00058" />
<option name="project" value="LOCAL" />
<updated>1517976806435</updated>
</task>
<option name="localTasksCounter" value="59" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
@ -998,7 +1009,7 @@
</history-entry> </history-entry>
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="121642000" /> <option name="totallyTimeSpent" value="121894000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -1057,7 +1068,6 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="pubspec" />
<MESSAGE value="Logging support" /> <MESSAGE value="Logging support" />
<MESSAGE value="Updated `use`" /> <MESSAGE value="Updated `use`" />
<MESSAGE value="+2" /> <MESSAGE value="+2" />
@ -1082,11 +1092,12 @@
<MESSAGE value="Used function syntax, deprecated `ResponseSerializer` typedef" /> <MESSAGE value="Used function syntax, deprecated `ResponseSerializer` typedef" />
<MESSAGE value="Deprecated all serving logic in `Angel`" /> <MESSAGE value="Deprecated all serving logic in `Angel`" />
<MESSAGE value="Removed use of `HttpHeaders` in `Angel`" /> <MESSAGE value="Removed use of `HttpHeaders` in `Angel`" />
<option name="LAST_COMMIT_MESSAGE" value="Removed use of `HttpHeaders` in `Angel`" /> <MESSAGE value="Deprecated createZoneForRequest" />
<option name="LAST_COMMIT_MESSAGE" value="Deprecated createZoneForRequest" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<option name="time" value="3" /> <option name="time" value="4" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
@ -1194,13 +1205,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="25" column="66" lean-forward="true" selection-start-line="25" selection-start-column="66" selection-end-line="25" selection-end-column="66" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/performance/hello/raw.dart"> <entry file="file://$PROJECT_DIR$/performance/hello/raw.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30"> <state relative-caret-position="30">
@ -1222,13 +1226,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/stats/metric_server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="183">
<caret line="113" column="27" lean-forward="true" selection-start-line="113" selection-start-column="27" selection-end-line="113" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/di_test.dart"> <entry file="file://$PROJECT_DIR$/test/di_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30"> <state relative-caret-position="30">
@ -1392,17 +1389,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="45">
<caret line="3" column="45" lean-forward="false" selection-start-line="3" selection-start-column="45" selection-end-line="3" selection-end-column="45" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/hooked_test.dart"> <entry file="file://$PROJECT_DIR$/test/hooked_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="647"> <state relative-caret-position="647">
@ -1456,25 +1442,50 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="120">
<caret line="8" column="3" lean-forward="true" selection-start-line="8" selection-start-column="3" selection-end-line="8" selection-end-column="3" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="41" lean-forward="false" selection-start-line="7" selection-start-column="41" selection-end-line="7" selection-end-column="41" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="273"> <state relative-caret-position="279">
<caret line="41" column="0" lean-forward="true" selection-start-line="41" selection-start-column="0" selection-end-line="41" selection-end-column="0" /> <caret line="27" column="64" lean-forward="false" selection-start-line="27" selection-start-column="64" selection-end-line="27" selection-end-column="64" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
<element signature="e#3455#3460#0" expanded="false" /> </folding>
<element signature="e#3763#3788#0" expanded="false" /> </state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/stats/metric_server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="65" column="61" lean-forward="false" selection-start-line="65" selection-start-column="61" selection-end-line="65" selection-end-column="61" />
<folding>
<marker date="1512571506000" expanded="true" signature="675:868" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="168"> <state relative-caret-position="135">
<caret line="44" column="29" lean-forward="true" selection-start-line="44" selection-start-column="29" selection-end-line="44" selection-end-column="29" /> <caret line="9" column="19" lean-forward="false" selection-start-line="9" selection-start-column="19" selection-end-line="9" selection-end-column="19" />
<folding> <folding />
<element signature="e#38#58#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>

View file

@ -2,6 +2,9 @@
* `ResponseContext` no longer automatically closes if `serializer` returns an * `ResponseContext` no longer automatically closes if `serializer` returns an
empty string. empty string.
* Added `autoSnakeCaseNames` to `MapService`. * Added `autoSnakeCaseNames` to `MapService`.
* Deprecated `Angel.createZoneForRequest`.
* Deprecated all `Angel` methods that directly touch an `HttpServer` or `HttpRequest`.
* Created the `AngelHttp` class.
# 1.1.0+3 # 1.1.0+3
* Modified `ResponseContext#isOpen` to also return `false` if streaming is being used. * Modified `ResponseContext#isOpen` to also return `false` if streaming is being used.

View file

@ -25,8 +25,12 @@ class AngelHttp {
AngelHttp(this.app); AngelHttp(this.app);
/// The function used to bind this instance to an HTTP server.
Future<HttpServer> Function(dynamic, int) get serverGenerator => _serverGenerator;
/// An instance mounted on a server started by the [serverGenerator]. /// An instance mounted on a server started by the [serverGenerator].
factory AngelHttp.custom(Angel app, ServerGenerator serverGenerator) { factory AngelHttp.custom(
Angel app, Future<HttpServer> Function(dynamic, int) serverGenerator) {
return new AngelHttp(app).._serverGenerator = serverGenerator; return new AngelHttp(app).._serverGenerator = serverGenerator;
} }
@ -45,7 +49,8 @@ class AngelHttp {
/// Provide paths to a certificate chain and server key (both .pem). /// Provide paths to a certificate chain and server key (both .pem).
/// If no password is provided, a random one will be generated upon running /// If no password is provided, a random one will be generated upon running
/// the server. /// the server.
factory AngelHttp.secure(Angel app, String certificateChainPath, String serverKeyPath, factory AngelHttp.secure(
Angel app, String certificateChainPath, String serverKeyPath,
{bool debug: false, String password}) { {bool debug: false, String password}) {
var certificateChain = var certificateChain =
Platform.script.resolve(certificateChainPath).toFilePath(); Platform.script.resolve(certificateChainPath).toFilePath();

View file

@ -3,7 +3,6 @@ library angel_framework.http;
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'server.dart' show ServerGenerator;
export 'package:angel_http_exception/angel_http_exception.dart'; export 'package:angel_http_exception/angel_http_exception.dart';
export 'package:angel_model/angel_model.dart'; export 'package:angel_model/angel_model.dart';
export 'package:angel_route/angel_route.dart'; export 'package:angel_route/angel_route.dart';
@ -25,8 +24,7 @@ export 'typed_service.dart';
Future<HttpServer> startShared(address, int port) => HttpServer Future<HttpServer> startShared(address, int port) => HttpServer
.bind(address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, shared: true); .bind(address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, shared: true);
/// Boots a secure shared server instance. Use this if launching multiple isolates Future<HttpServer> Function(dynamic, int) startSharedSecure(SecurityContext securityContext) {
ServerGenerator startSharedSecure(SecurityContext securityContext) {
return (address, int port) => HttpServer.bindSecure( return (address, int port) => HttpServer.bindSecure(
address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, securityContext, address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, securityContext,
shared: true); shared: true);

View file

@ -22,6 +22,9 @@ import 'service.dart';
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)'); final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
/// A function that binds an [Angel] server to an Internet address and port. /// A function that binds an [Angel] server to an Internet address and port.
///
/// Prefer the Future<HttpServer> Function(dynamic, int) syntax.
@deprecated
typedef Future<HttpServer> ServerGenerator(address, int port); typedef Future<HttpServer> ServerGenerator(address, int port);
/// A function that configures an [Angel] server in some way. /// A function that configures an [Angel] server in some way.
@ -37,7 +40,7 @@ class Angel extends AngelBase {
AngelHttp _http; AngelHttp _http;
bool _isProduction; bool _isProduction;
Angel _parent; Angel _parent;
ServerGenerator _serverGenerator = HttpServer.bind; Future<HttpServer> Function(dynamic, int) _serverGenerator = HttpServer.bind;
/// A global Map of converters that can transform responses bodies. /// A global Map of converters that can transform responses bodies.
final Map<String, Converter<List<int>, List<int>>> encoders = {}; final Map<String, Converter<List<int>, List<int>>> encoders = {};
@ -85,8 +88,9 @@ class Angel extends AngelBase {
(Platform.environment['ANGEL_ENV'] == 'production'); (Platform.environment['ANGEL_ENV'] == 'production');
} }
/// The function used to bind this instance to an HTTP server. /// Use the serving methods in [AngelHttp] instead.
ServerGenerator get serverGenerator => _serverGenerator; @deprecated
ServerGenerator get serverGenerator => _http.serverGenerator;
/// Returns the parent instance of this application, if any. /// Returns the parent instance of this application, if any.
Angel get parent => _parent; Angel get parent => _parent;
@ -497,7 +501,7 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead. /// Use the serving methods in [AngelHttp] instead.
@deprecated @deprecated
factory Angel.custom(ServerGenerator serverGenerator) { factory Angel.custom(Future<HttpServer> Function(dynamic, int) serverGenerator) {
var app = new Angel(); var app = new Angel();
return app.._http = new AngelHttp.custom(app, serverGenerator); return app.._http = new AngelHttp.custom(app, serverGenerator);
} }