2.0.0-alpha.12

This commit is contained in:
Tobe O 2018-11-13 13:07:27 -05:00
parent 930c2629af
commit 8f8bc6cf20
4 changed files with 120 additions and 105 deletions

View file

@ -1,117 +1,134 @@
# 2.0.0-alpha.12
- Remove `ResponseContext.sendFile`.
- Add `Angel.mimeTypeResolver`.
- Fix a bug where an unknown MIME type on `streamFile` would return a 500.
# 2.0.0-alpha.11 # 2.0.0-alpha.11
* Add `readMany` to `Service`.
* Allow `ResponseContext.redirect` to take a `Uri`. - Add `readMany` to `Service`.
* Add `Angel.mountController`. - Allow `ResponseContext.redirect` to take a `Uri`.
* Add `Angel.findServiceOf`. - Add `Angel.mountController`.
* Roll in HTTP/2. See `pkg:angel_framework/http2.dart`. - Add `Angel.findServiceOf`.
- Roll in HTTP/2. See `pkg:angel_framework/http2.dart`.
# 2.0.0-alpha.10 # 2.0.0-alpha.10
* All calls to `Service.parseId` are now affixed with the `<Id>` argument.
* Added `uri` getter to `AngelHttp`. - All calls to `Service.parseId` are now affixed with the `<Id>` argument.
* The default for `parseQuery` now wraps query parameters in `new Map<String, dynamic>.from`. - Added `uri` getter to `AngelHttp`.
This resolves a bug in `package:angel_validate`. - The default for `parseQuery` now wraps query parameters in `new Map<String, dynamic>.from`.
This resolves a bug in `package:angel_validate`.
# 2.0.0-alpha.9 # 2.0.0-alpha.9
* Add `Service.map`.
- Add `Service.map`.
# 2.0.0-alpha.8 # 2.0.0-alpha.8
* No longer export HTTP-specific code from `angel_framework.dart`.
An import of `import 'package:angel_framework/http.dart';` will be necessary in most cases now. - No longer export HTTP-specific code from `angel_framework.dart`.
An import of `import 'package:angel_framework/http.dart';` will be necessary in most cases now.
# 2.0.0-alpha.7 # 2.0.0-alpha.7
* Force a tigher contract on services. They now must return `Data` on all
methods except for `index`, which returns a `List<Data>`. - Force a tigher contract on services. They now must return `Data` on all
methods except for `index`, which returns a `List<Data>`.
# 2.0.0-alpha.6 # 2.0.0-alpha.6
* Allow passing a custom `Container` to `handleContained` and co.
- Allow passing a custom `Container` to `handleContained` and co.
# 2.0.0-alpha.5 # 2.0.0-alpha.5
* `MapService` methods now explicitly return `Map<String, dynamic>`.
- `MapService` methods now explicitly return `Map<String, dynamic>`.
# 2.0.0-alpha.4 # 2.0.0-alpha.4
* Renamed `waterfall` to `chain`.
* Renamed `Routable.service` to `Routable.findService`. - Renamed `waterfall` to `chain`.
* Also `Routable.findHookedService`. - Renamed `Routable.service` to `Routable.findService`.
- Also `Routable.findHookedService`.
# 2.0.0-alpha.3 # 2.0.0-alpha.3
* Added `<Id, Data>` type parameters to `Service`.
* `HookedService` now follows suit, and takes a third parameter, pointing to the inner service. - Added `<Id, Data>` type parameters to `Service`.
* `Routable.use` now uses the generic parameters added to `Service`. - `HookedService` now follows suit, and takes a third parameter, pointing to the inner service.
* Added generic usage to `HookedServiceListener`, etc. - `Routable.use` now uses the generic parameters added to `Service`.
* All service methods take `Map<String, dynamic>` as `params` now. - Added generic usage to `HookedServiceListener`, etc.
- All service methods take `Map<String, dynamic>` as `params` now.
# 2.0.0-alpha.2 # 2.0.0-alpha.2
* Added `ResponseContext.detach`.
- Added `ResponseContext.detach`.
# 2.0.0-alpha.1 # 2.0.0-alpha.1
* Removed `Angel.injectEncoders`.
* Added `Providers.toJson`. - Removed `Angel.injectEncoders`.
* Moved `Providers.graphql` to `Providers.graphQL`. - Added `Providers.toJson`.
* `Angel.optimizeForProduction` no longer calls `preInject`, - Moved `Providers.graphql` to `Providers.graphQL`.
as it does not need to. - `Angel.optimizeForProduction` no longer calls `preInject`,
* Rename `ResponseContext.enableBuffer` to `ResponseContext.useBuffer`. as it does not need to.
- Rename `ResponseContext.enableBuffer` to `ResponseContext.useBuffer`.
# 2.0.0-alpha # 2.0.0-alpha
* Removed `random_string` dependency.
* Moved reflection to `package:angel_container`. - Removed `random_string` dependency.
* Upgraded `package:file` to `5.0.0`. - Moved reflection to `package:angel_container`.
* `ResponseContext.sendFile` now uses `package:file`. - Upgraded `package:file` to `5.0.0`.
* Abandon `ContentType` in favor of `MediaType`. - `ResponseContext.sendFile` now uses `package:file`.
* Changed view engine to use `Map<String, dynamic>`. - Abandon `ContentType` in favor of `MediaType`.
* Remove dependency on `package:json_god` by default. - Changed view engine to use `Map<String, dynamic>`.
* Remove dependency on `package:dart2_constant`. - Remove dependency on `package:json_god` by default.
* Moved `lib/hooks.dart` into `package:angel_hooks`. - Remove dependency on `package:dart2_constant`.
* Moved `TypedService` into `package:angel_typed_service`. - Moved `lib/hooks.dart` into `package:angel_hooks`.
* Completely removed the `AngelBase` class. - Moved `TypedService` into `package:angel_typed_service`.
* Removed all `@deprecated` symbols. - Completely removed the `AngelBase` class.
* `Service.toId` was renamed to `Service.parseId`; it also now uses its - Removed all `@deprecated` symbols.
single type argument to determine how to parse a value. - `Service.toId` was renamed to `Service.parseId`; it also now uses its
* In addition, this method was also made `static`. single type argument to determine how to parse a value. \* In addition, this method was also made `static`.
* `RequestContext` and `ResponseContext` are now generic, and take a - `RequestContext` and `ResponseContext` are now generic, and take a
single type argument pointing to the underlying request/response type, single type argument pointing to the underlying request/response type,
respectively. respectively.
* `RequestContext.io` and `ResponseContext.io` are now permanently - `RequestContext.io` and `ResponseContext.io` are now permanently
gone. gone.
* `HttpRequestContextImpl` and `HttpResponseContextImpl` were renamed to - `HttpRequestContextImpl` and `HttpResponseContextImpl` were renamed to
`HttpRequestContext` and `HttpResponseContext`. `HttpRequestContext` and `HttpResponseContext`.
* Lazy-parsing request bodies is now the default; `Angel.lazyParseBodies` was replaced - Lazy-parsing request bodies is now the default; `Angel.lazyParseBodies` was replaced
with `Angel.eagerParseRequestBodies`. with `Angel.eagerParseRequestBodies`.
* `Angel.storeOriginalBuffer` -> `Angel.storeRawRequestBuffers`. - `Angel.storeOriginalBuffer` -> `Angel.storeRawRequestBuffers`.
* The methods `lazyBody`, `lazyFiles`, and `lazyOriginalBuffer` on `ResponseContext` were all - The methods `lazyBody`, `lazyFiles`, and `lazyOriginalBuffer` on `ResponseContext` were all
replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, respectively. replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, respectively.
* Removed the synchronous equivalents of the above methods (`body`, `files`, and `originalBuffer`), - Removed the synchronous equivalents of the above methods (`body`, `files`, and `originalBuffer`),
as well as `query`. as well as `query`.
* Removed `Angel.injections` and `RequestContext.injections`. - Removed `Angel.injections` and `RequestContext.injections`.
* Removed `Angel.inject` and `RequestContext.inject`. - Removed `Angel.inject` and `RequestContext.inject`.
* Removed a dependency on `package:pool`, which also meant removing `AngelHttp.throttle`. - Removed a dependency on `package:pool`, which also meant removing `AngelHttp.throttle`.
* Remove the `RequestMiddleware` typedef; from now on, one should use `ResponseContext.end` - Remove the `RequestMiddleware` typedef; from now on, one should use `ResponseContext.end`
exclusively to close responses. exclusively to close responses.
* `waterfall` will now only accept `RequestHandler`. - `waterfall` will now only accept `RequestHandler`.
* `Routable`, and all of its subclasses, now extend `Router<RequestHandler>`, and therefore only - `Routable`, and all of its subclasses, now extend `Router<RequestHandler>`, and therefore only
take routes in the form of `FutureOr myFunc(RequestContext, ResponseContext res)`. take routes in the form of `FutureOr myFunc(RequestContext, ResponseContext res)`.
* `@Middleware` now takes an `Iterable` of `RequestHandler`s. - `@Middleware` now takes an `Iterable` of `RequestHandler`s.
* `@Expose.path` now *must* be a `String`, not just any `Pattern`. - `@Expose.path` now _must_ be a `String`, not just any `Pattern`.
* `@Expose.middleware` now takes `Iterable<RequestHandler>`, instead of just `List`. - `@Expose.middleware` now takes `Iterable<RequestHandler>`, instead of just `List`.
* `createDynamicHandler` was renamed to `ioc`, and is now used to run IoC-aware handlers in a - `createDynamicHandler` was renamed to `ioc`, and is now used to run IoC-aware handlers in a
type-safe manner. type-safe manner.
* `RequestContext.params` is now a `Map<String, dynamic>`, rather than just a `Map`. - `RequestContext.params` is now a `Map<String, dynamic>`, rather than just a `Map`.
* Removed `RequestContext.grab`. - Removed `RequestContext.grab`.
* Removed `RequestContext.properties`. - Removed `RequestContext.properties`.
* Removed the defunct `debug` property where it still existed. - Removed the defunct `debug` property where it still existed.
* `Routable.use` now only accepts a `Service`. - `Routable.use` now only accepts a `Service`.
* Removed `Angel.createZoneForRequest`. - Removed `Angel.createZoneForRequest`.
* Removed `Angel.defaultZoneCreator`. - Removed `Angel.defaultZoneCreator`.
* Added all flags to the `Angel` constructor, ex. `Angel.eagerParseBodies`. - Added all flags to the `Angel` constructor, ex. `Angel.eagerParseBodies`.
* Fix a bug where synchronous errors in `handleRequest` would not be caught. - Fix a bug where synchronous errors in `handleRequest` would not be caught.
* `AngelHttp.useZone` now defaults to `false`. - `AngelHttp.useZone` now defaults to `false`.
* `ResponseContext` now starts in streaming mode by default; the response buffer is opt-in, - `ResponseContext` now starts in streaming mode by default; the response buffer is opt-in,
as in many cases it is unnecessary and slows down response time. as in many cases it is unnecessary and slows down response time.
* `ResponseContext.streaming` was replaced by `ResponseContext.isBuffered`. - `ResponseContext.streaming` was replaced by `ResponseContext.isBuffered`.
* Made `LockableBytesBuilder` public. - Made `LockableBytesBuilder` public.
* Removed the now-obsolete `ResponseContext.willCloseItself`. - Removed the now-obsolete `ResponseContext.willCloseItself`.
* Removed `ResponseContext.dispose`. - Removed `ResponseContext.dispose`.
* Removed the now-obsolete `ResponseContext.end`. - Removed the now-obsolete `ResponseContext.end`.
* Removed the now-obsolete `ResponseContext.releaseCorrespondingRequest`. - Removed the now-obsolete `ResponseContext.releaseCorrespondingRequest`.
* `preInject` now takes a `Reflector` as its second argument. - `preInject` now takes a `Reflector` as its second argument.
* `Angel.reflector` defaults to `const EmptyReflector()`, disabling - `Angel.reflector` defaults to `const EmptyReflector()`, disabling
reflection out-of-the-box. reflection out-of-the-box.

View file

@ -276,15 +276,6 @@ abstract class ResponseContext<RawResponse>
redirect('$head/$tail'.replaceAll(_straySlashes, ''), code: code); redirect('$head/$tail'.replaceAll(_straySlashes, ''), code: code);
} }
/// Copies a file's contents into the response buffer.
void sendFile(File file) {
if (!isOpen) throw closed();
contentType = MediaType.parse(lookupMimeType(file.path));
buffer.add(file.readAsBytesSync());
close();
}
/// Serializes data to the response. /// Serializes data to the response.
bool serialize(value, {MediaType contentType}) { bool serialize(value, {MediaType contentType}) {
if (!isOpen) throw closed(); if (!isOpen) throw closed();
@ -299,7 +290,10 @@ abstract class ResponseContext<RawResponse>
/// Streams a file to this response. /// Streams a file to this response.
Future streamFile(File file) { Future streamFile(File file) {
if (!isOpen) throw closed(); if (!isOpen) throw closed();
contentType = MediaType.parse(lookupMimeType(file.path)); var mimeType = app.mimeTypeResolver.lookup(file.path);
contentType = mimeType == null
? new MediaType('application', 'octet-stream')
: MediaType.parse(mimeType);
return file.openRead().pipe(this); return file.openRead().pipe(this);
} }

View file

@ -11,6 +11,7 @@ import 'package:angel_route/angel_route.dart';
import 'package:combinator/combinator.dart'; import 'package:combinator/combinator.dart';
import 'package:http_parser/http_parser.dart'; import 'package:http_parser/http_parser.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:mime/mime.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'controller.dart'; import 'controller.dart';
@ -48,6 +49,9 @@ class Angel extends Routable {
final Map<dynamic, InjectionRequest> _preContained = {}; final Map<dynamic, InjectionRequest> _preContained = {};
/// A [MimeTypeResolver] that can be used to specify the MIME types of files not known by `package:mime`.
final MimeTypeResolver mimeTypeResolver = new MimeTypeResolver();
/// A middleware to inject a serialize on every request. /// A middleware to inject a serialize on every request.
String Function(dynamic) serializer; String Function(dynamic) serializer;

View file

@ -1,5 +1,5 @@
name: angel_framework name: angel_framework
version: 2.0.0-alpha.11 version: 2.0.0-alpha.12
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