65
This commit is contained in:
parent
d869210de8
commit
4e51d87b61
3 changed files with 23 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
# angel_framework
|
# 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)
|
[![build status](https://travis-ci.org/angel-dart/framework.svg)](https://travis-ci.org/angel-dart/framework)
|
||||||
|
|
||||||
Core libraries for the Angel Framework.
|
Core libraries for the Angel Framework.
|
||||||
|
|
|
@ -139,6 +139,22 @@ class Angel extends AngelBase {
|
||||||
container.singleton(this);
|
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.
|
/// Runs some [handler]. Returns `true` if request execution should continue.
|
||||||
Future<bool> executeHandler(
|
Future<bool> executeHandler(
|
||||||
handler, RequestContext req, ResponseContext res) async {
|
handler, RequestContext req, ResponseContext res) async {
|
||||||
|
@ -265,9 +281,11 @@ class Angel extends AngelBase {
|
||||||
accept.contains('*/*') ||
|
accept.contains('*/*') ||
|
||||||
accept.contains(ContentType.JSON.mimeType) ||
|
accept.contains(ContentType.JSON.mimeType) ||
|
||||||
accept.contains("application/javascript")) {
|
accept.contains("application/javascript")) {
|
||||||
res.serialize(e.toMap());
|
res.serialize(e.toMap(),
|
||||||
|
contentType: res.headers[HttpHeaders.CONTENT_TYPE] ??
|
||||||
|
ContentType.JSON.mimeType);
|
||||||
} else {
|
} else {
|
||||||
await _errorHandler(e, req, res);
|
await errorHandler(e, req, res);
|
||||||
}
|
}
|
||||||
// _finalizeResponse(request, res);
|
// _finalizeResponse(request, res);
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_framework
|
name: angel_framework
|
||||||
version: 1.0.0-dev.64
|
version: 1.0.0-dev.65
|
||||||
description: Core libraries for the Angel framework.
|
description: Core libraries for the Angel framework.
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue