This commit is contained in:
thosakwe 2017-03-05 19:52:16 -05:00
parent d869210de8
commit 4e51d87b61
3 changed files with 23 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# angel_framework
[![pub 1.0.0-dev.64](https://img.shields.io/badge/pub-1.0.0--dev.64-red.svg)](https://pub.dartlang.org/packages/angel_framework)
[![pub 1.0.0-dev.65](https://img.shields.io/badge/pub-1.0.0--dev.65-red.svg)](https://pub.dartlang.org/packages/angel_framework)
[![build status](https://travis-ci.org/angel-dart/framework.svg)](https://travis-ci.org/angel-dart/framework)
Core libraries for the Angel Framework.
@ -19,4 +19,4 @@ main() async {
await app.startServer();
}
```
```

View file

@ -139,6 +139,22 @@ class Angel extends AngelBase {
container.singleton(this);
}
/// Shortcut for adding a middleware to inject a key/value pair on every request.
void inject(key, value) {
before.add((RequestContext req, ResponseContext res) async {
req.inject(key, value);
return true;
});
}
/// Shortcut for adding a middleware to inject a serialize on every request.
void injectSerializer(ResponseSerializer serializer) {
before.add((RequestContext req, ResponseContext res) async {
res.serializer = serialize;
return true;
});
}
/// Runs some [handler]. Returns `true` if request execution should continue.
Future<bool> executeHandler(
handler, RequestContext req, ResponseContext res) async {
@ -265,9 +281,11 @@ class Angel extends AngelBase {
accept.contains('*/*') ||
accept.contains(ContentType.JSON.mimeType) ||
accept.contains("application/javascript")) {
res.serialize(e.toMap());
res.serialize(e.toMap(),
contentType: res.headers[HttpHeaders.CONTENT_TYPE] ??
ContentType.JSON.mimeType);
} else {
await _errorHandler(e, req, res);
await errorHandler(e, req, res);
}
// _finalizeResponse(request, res);
} catch (e, st) {

View file

@ -1,5 +1,5 @@
name: angel_framework
version: 1.0.0-dev.64
version: 1.0.0-dev.65
description: Core libraries for the Angel framework.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework