Need to migrate to JSON God v2, this is a breaking change
This commit is contained in:
parent
42023ca374
commit
267b696150
3 changed files with 23 additions and 34 deletions
|
@ -7,7 +7,7 @@ import 'dart:io';
|
|||
import 'dart:math';
|
||||
import 'dart:mirrors';
|
||||
import 'package:body_parser/body_parser.dart';
|
||||
import 'package:json_god/json_god.dart';
|
||||
import 'package:json_god/json_god.dart' as god;
|
||||
import 'package:merge_map/merge_map.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
|
@ -21,4 +21,4 @@ part 'routable.dart';
|
|||
part 'server.dart';
|
||||
part 'service.dart';
|
||||
part 'service_hooked.dart';
|
||||
part 'services/memory.dart';
|
||||
part 'services/memory.dart';
|
||||
|
|
|
@ -4,8 +4,8 @@ part of angel_framework.http;
|
|||
typedef Future<HttpServer> ServerGenerator(InternetAddress address, int port);
|
||||
|
||||
/// Handles an [AngelHttpException].
|
||||
typedef Future AngelErrorHandler(AngelHttpException err, RequestContext req,
|
||||
ResponseContext res);
|
||||
typedef Future AngelErrorHandler(
|
||||
AngelHttpException err, RequestContext req, ResponseContext res);
|
||||
|
||||
/// A function that configures an [Angel] server in some way.
|
||||
typedef Future AngelConfigurer(Angel app);
|
||||
|
@ -38,18 +38,16 @@ class Angel extends Routable {
|
|||
List after = [];
|
||||
|
||||
HttpServer httpServer;
|
||||
God god = new God();
|
||||
|
||||
startServer(InternetAddress address, int port) async {
|
||||
var server =
|
||||
await _serverGenerator(address ?? InternetAddress.LOOPBACK_IP_V4, port);
|
||||
await _serverGenerator(address ?? InternetAddress.LOOPBACK_IP_V4, port);
|
||||
this.httpServer = server;
|
||||
|
||||
server.listen((HttpRequest request) async {
|
||||
String req_url = request.uri.toString().replaceAll(
|
||||
new RegExp(r'\/+$'), '');
|
||||
if (req_url.isEmpty)
|
||||
req_url = '/';
|
||||
String req_url =
|
||||
request.uri.toString().replaceAll(new RegExp(r'\/+$'), '');
|
||||
if (req_url.isEmpty) req_url = '/';
|
||||
RequestContext req = await RequestContext.from(request, {}, this, null);
|
||||
ResponseContext res = await ResponseContext.from(request.response, this);
|
||||
|
||||
|
@ -109,8 +107,8 @@ class Angel extends Routable {
|
|||
return server;
|
||||
}
|
||||
|
||||
Future<bool> _applyHandler(handler, RequestContext req,
|
||||
ResponseContext res) async {
|
||||
Future<bool> _applyHandler(
|
||||
handler, RequestContext req, ResponseContext res) async {
|
||||
if (handler is RequestMiddleware) {
|
||||
var result = await handler(req, res);
|
||||
if (result is bool)
|
||||
|
@ -191,8 +189,8 @@ class Angel extends Routable {
|
|||
if (routable is Service) {
|
||||
routable.app = this;
|
||||
}
|
||||
super.use(
|
||||
path, routable, hooked: hooked, middlewareNamespace: middlewareNamespace);
|
||||
super.use(path, routable,
|
||||
hooked: hooked, middlewareNamespace: middlewareNamespace);
|
||||
}
|
||||
|
||||
onError(handler) {
|
||||
|
@ -205,27 +203,18 @@ class Angel extends Routable {
|
|||
if (stackTrace != null) stderr.write(stackTrace.toString());
|
||||
}
|
||||
|
||||
Angel
|
||||
()
|
||||
:
|
||||
super() {}
|
||||
Angel() : super() {}
|
||||
|
||||
/// Creates an HTTPS server.
|
||||
/// Provide paths to a certificate chain and server key (both .pem).
|
||||
/// If no password is provided, a random one will be generated upon running
|
||||
/// the server.
|
||||
Angel.secure
|
||||
(String certificateChainPath, String
|
||||
serverKeyPath
|
||||
,
|
||||
{
|
||||
String password
|
||||
})
|
||||
: super()
|
||||
{
|
||||
Angel.secure(String certificateChainPath, String serverKeyPath,
|
||||
{String password})
|
||||
: super() {
|
||||
_serverGenerator = (InternetAddress address, int port) async {
|
||||
var certificateChain =
|
||||
Platform.script.resolve('server_chain.pem').toFilePath();
|
||||
Platform.script.resolve('server_chain.pem').toFilePath();
|
||||
var serverKey = Platform.script.resolve('server_key.pem').toFilePath();
|
||||
var serverContext = new SecurityContext();
|
||||
serverContext.useCertificateChain(certificateChain);
|
||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -4,10 +4,10 @@ description: Core libraries for the Angel framework.
|
|||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_framework
|
||||
dependencies:
|
||||
body_parser: ^1.0.0-dev
|
||||
json_god: ^1.0.0
|
||||
merge_map: ^1.0.0
|
||||
mime: ^0.9.3
|
||||
body_parser: ">=1.0.0-dev <2.0.0"
|
||||
json_god: ">=2.0.0-beta <3.0.0"
|
||||
merge_map: ">=1.0.0 <2.0.0"
|
||||
mime: ">=0.9.3 <1.0.0"
|
||||
dev_dependencies:
|
||||
http: ^0.11.3
|
||||
test: ^0.12.13
|
||||
http: ">= 0.11.3 < 0.12.0"
|
||||
test: ">= 0.12.13 < 0.13.0"
|
Loading…
Reference in a new issue