72!
This commit is contained in:
parent
e254d9791d
commit
9683e97603
5 changed files with 35 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
# angel_framework
|
||||
|
||||
[![pub 1.0.0-dev.71](https://img.shields.io/badge/pub-1.0.0--dev.71-red.svg)](https://pub.dartlang.org/packages/angel_framework)
|
||||
[![pub 1.0.0-dev.72](https://img.shields.io/badge/pub-1.0.0--dev.72-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)
|
||||
|
||||
A high-powered HTTP server with support for dependency injection, sophisticated routing and more.
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'common.dart';
|
||||
|
||||
main() async {
|
||||
int x = 0;
|
||||
|
|
|
@ -129,6 +129,14 @@ class ResponseContext extends Extensible {
|
|||
_isOpen = false;
|
||||
}
|
||||
|
||||
/// Re-opens a closed response. **NEVER USE THIS IN A PLUGIN**.
|
||||
///
|
||||
/// To preserve your sanity, don't use it ever. This is solely for internal use.
|
||||
void reopen() {
|
||||
_buffer._reopen();
|
||||
_isOpen = true;
|
||||
}
|
||||
|
||||
/// Sets a response header to the given value, or retrieves its value.
|
||||
@Deprecated('Please use `headers` instead.')
|
||||
header(String key, [String value]) {
|
||||
|
@ -312,6 +320,7 @@ class ResponseContext extends Extensible {
|
|||
abstract class _LockableBytesBuilder extends BytesBuilder {
|
||||
factory _LockableBytesBuilder() => new _LockableBytesBuilderImpl();
|
||||
void _lock();
|
||||
void _reopen();
|
||||
}
|
||||
|
||||
class _LockableBytesBuilderImpl implements _LockableBytesBuilder {
|
||||
|
@ -326,6 +335,11 @@ class _LockableBytesBuilderImpl implements _LockableBytesBuilder {
|
|||
_closed = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void _reopen() {
|
||||
_closed = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void add(List<int> bytes) {
|
||||
if (_closed)
|
||||
|
|
|
@ -153,13 +153,24 @@ class Angel extends AngelBase {
|
|||
{List middleware: const []}) {
|
||||
if (_flattened != null) {
|
||||
print(
|
||||
'WARNING: You added a route ($method $path) to the router, after it has been optimized.');
|
||||
'WARNING: You added a route ($method $path) to the router, after it had been optimized.');
|
||||
print('This route will be ignored, and no requests will ever reach it.');
|
||||
}
|
||||
|
||||
return super.addRoute(method, path, handler, middleware: middleware ?? []);
|
||||
}
|
||||
|
||||
@override
|
||||
mount(Pattern path, Router router, {bool hooked: true, String namespace}) {
|
||||
if (_flattened != null) {
|
||||
print(
|
||||
'WARNING: You added mounted a child router ($path) on the router, after it had been optimized.');
|
||||
print('This route will be ignored, and no requests will ever reach it.');
|
||||
}
|
||||
return super
|
||||
.mount(path, router, hooked: hooked != false, namespace: namespace);
|
||||
}
|
||||
|
||||
/// Loads some base dependencies into the service container.
|
||||
void bootstrapContainer() {
|
||||
if (runtimeType != Angel) container.singleton(this, as: Angel);
|
||||
|
@ -400,7 +411,9 @@ class Angel extends AngelBase {
|
|||
.forEach(_walk);
|
||||
}
|
||||
|
||||
_walk(_flattened = flatten(this));
|
||||
if (_flattened == null) _flattened = flatten(this);
|
||||
|
||||
_walk(_flattened);
|
||||
print('Angel is running in production mode.');
|
||||
}
|
||||
}
|
||||
|
@ -438,10 +451,14 @@ class Angel extends AngelBase {
|
|||
_afterProcessed.add(request);
|
||||
|
||||
if (!res.willCloseItself) {
|
||||
res.reopen();
|
||||
|
||||
for (var finalizer in responseFinalizers) {
|
||||
await finalizer(req, res);
|
||||
}
|
||||
|
||||
if (res.isOpen) res.end();
|
||||
|
||||
for (var key in res.headers.keys) {
|
||||
request.response.headers.add(key, res.headers[key]);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_framework
|
||||
version: 1.0.0-dev.71
|
||||
version: 1.0.0-dev.72
|
||||
description: A high-powered HTTP server with DI, routing and more.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_framework
|
||||
|
|
Loading…
Reference in a new issue