Updated to 6.0.0

This commit is contained in:
thomashii 2022-02-14 00:48:37 +08:00
parent bab4e5eaf6
commit dfd974c106
21 changed files with 124 additions and 52 deletions

View file

@ -1,5 +1,18 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
* Removed `error`
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.1
* Updated `_ReflectedMethodMirror` to have optional `returnType` parameter

View file

@ -1,10 +1,10 @@
name: angel3_container
version: 3.1.1
version: 6.0.0
description: Angel3 hierarchical DI container, and pluggable backends for reflection.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dependencies:
collection: ^1.15.0
quiver: ^3.0.1

View file

@ -1,5 +1,13 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.2.4
* Fixed issue 48. Log not working in development
@ -356,7 +364,7 @@ stable, there'll be a conversion, perhaps.
* `Routable`, and all of its subclasses, now extend `Router<RequestHandler>`, and therefore only
take routes in the form of `FutureOr myFunc(RequestContext, ResponseContext res)`.
* `@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`.
* `createDynamicHandler` was renamed to `ioc`, and is now used to run IoC-aware handlers in a
type-safe manner.

View file

@ -185,7 +185,7 @@ abstract class Driver<
throw AngelHttpException.badRequest(message: e.message)
..stackTrace = st;
}
throw AngelHttpException(e,
throw AngelHttpException(
stackTrace: st,
statusCode: (e is AngelHttpException) ? e.statusCode : 500,
message: e?.toString() ?? '500 Internal Server Error');
@ -198,7 +198,7 @@ abstract class Driver<
if (ee is AngelHttpException) {
e = ee;
} else {
e = AngelHttpException(ee,
e = AngelHttpException(
stackTrace: st,
statusCode: 500,
message: ee?.toString() ?? '500 Internal Server Error');
@ -233,7 +233,7 @@ abstract class Driver<
} else if (error is AngelHttpException) {
e = error;
} else {
e = AngelHttpException(error,
e = AngelHttpException(
stackTrace: stackTrace, message: error.toString());
}

View file

@ -1,5 +1,5 @@
name: angel3_framework
version: 4.2.4
version: 6.0.0
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework
@ -38,3 +38,11 @@ dev_dependencies:
dependency_overrides:
angel3_container:
path: ../container/angel_container
angel3_http_exception:
path: ../http_exception
angel3_model:
path: ../model
angel3_route:
path: ../route
angel3_mock_request:
path: ../mock_request

View file

@ -1,6 +1,5 @@
import 'package:angel3_framework/angel3_framework.dart';
import 'dart:convert';
import 'package:matcher/matcher.dart';
import 'package:test/test.dart';
void main() {
@ -41,9 +40,7 @@ void main() {
});
test('toString', () {
expect(
AngelHttpException(null, statusCode: 420, message: 'Blaze It')
.toString(),
expect(AngelHttpException(statusCode: 420, message: 'Blaze It').toString(),
'420: Blaze It');
});
}

View file

@ -5,7 +5,6 @@ import 'dart:io';
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:matcher/matcher.dart';
import 'package:angel3_mock_request/angel3_mock_request.dart';
import 'package:test/test.dart';
@ -46,7 +45,7 @@ void main() {
var rs = rq.response;
var req = await http.createRequestContext(rq, rs);
var res = await http.createResponseContext(rq, rs);
var e = AngelHttpException(null,
var e = AngelHttpException(
statusCode: 321, message: 'Hello', errors: ['foo', 'bar']);
await app.errorHandler(e, req, res);
await http.sendResponse(rq, rs, req, res);

View file

@ -1,6 +1,19 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
* Removed `error`
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.0
* Upgraded to `lints` linter

View file

@ -9,11 +9,12 @@ import 'dart:convert';
/// Originally inspired by
/// [feathers-errors](https://github.com/feathersjs/feathers-errors).
class AngelHttpException implements Exception {
var error;
/// A list of errors that occurred when this exception was thrown.
final List<String> errors = [];
/// The cause of this exception.
dynamic error;
/// The cause of this exception.
String message;
@ -23,7 +24,7 @@ class AngelHttpException implements Exception {
/// An HTTP status code this exception will throw.
int statusCode;
AngelHttpException(this.error,
AngelHttpException(
{this.message = '500 Internal Server Error',
this.stackTrace,
this.statusCode = 500,
@ -49,7 +50,6 @@ class AngelHttpException implements Exception {
factory AngelHttpException.fromMap(Map data) {
return AngelHttpException(
null,
statusCode: (data['status_code'] ?? data['statusCode'] ?? 500) as int,
message: data['message']?.toString() ?? 'Internal Server Error',
errors: data['errors'] is Iterable
@ -66,57 +66,56 @@ class AngelHttpException implements Exception {
factory AngelHttpException.badRequest(
{String message = '400 Bad Request',
List<String> errors = const []}) =>
AngelHttpException(null,
message: message, errors: errors, statusCode: 400);
AngelHttpException(message: message, errors: errors, statusCode: 400);
/// Throws a 401 Not Authenticated error.
factory AngelHttpException.notAuthenticated(
{String message = '401 Not Authenticated'}) =>
AngelHttpException(null, message: message, statusCode: 401);
AngelHttpException(message: message, statusCode: 401);
/// Throws a 402 Payment Required error.
factory AngelHttpException.paymentRequired(
{String message = '402 Payment Required'}) =>
AngelHttpException(null, message: message, statusCode: 402);
AngelHttpException(message: message, statusCode: 402);
/// Throws a 403 Forbidden error.
factory AngelHttpException.forbidden({String message = '403 Forbidden'}) =>
AngelHttpException(null, message: message, statusCode: 403);
AngelHttpException(message: message, statusCode: 403);
/// Throws a 404 Not Found error.
factory AngelHttpException.notFound({String message = '404 Not Found'}) =>
AngelHttpException(null, message: message, statusCode: 404);
AngelHttpException(message: message, statusCode: 404);
/// Throws a 405 Method Not Allowed error.
factory AngelHttpException.methodNotAllowed(
{String message = '405 Method Not Allowed'}) =>
AngelHttpException(null, message: message, statusCode: 405);
AngelHttpException(message: message, statusCode: 405);
/// Throws a 406 Not Acceptable error.
factory AngelHttpException.notAcceptable(
{String message = '406 Not Acceptable'}) =>
AngelHttpException(null, message: message, statusCode: 406);
AngelHttpException(message: message, statusCode: 406);
/// Throws a 408 Timeout error.
factory AngelHttpException.methodTimeout({String message = '408 Timeout'}) =>
AngelHttpException(null, message: message, statusCode: 408);
AngelHttpException(message: message, statusCode: 408);
/// Throws a 409 Conflict error.
factory AngelHttpException.conflict({String message = '409 Conflict'}) =>
AngelHttpException(null, message: message, statusCode: 409);
AngelHttpException(message: message, statusCode: 409);
/// Throws a 422 Not Processable error.
factory AngelHttpException.notProcessable(
{String message = '422 Not Processable'}) =>
AngelHttpException(null, message: message, statusCode: 422);
AngelHttpException(message: message, statusCode: 422);
/// Throws a 501 Not Implemented error.
factory AngelHttpException.notImplemented(
{String message = '501 Not Implemented'}) =>
AngelHttpException(null, message: message, statusCode: 501);
AngelHttpException(message: message, statusCode: 501);
/// Throws a 503 Unavailable error.
factory AngelHttpException.unavailable(
{String message = '503 Unavailable'}) =>
AngelHttpException(null, message: message, statusCode: 503);
AngelHttpException(message: message, statusCode: 503);
}

View file

@ -1,9 +1,9 @@
name: angel3_http_exception
version: 3.1.0
version: 6.0.0
description: Exception class that can be serialized to JSON and serialized to clients.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/http_exception
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dev_dependencies:
lints: ^1.0.0

View file

@ -1,5 +1,21 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.0.0
* No release. Skipped
## 3.0.0
* No release. Skipped
## 2.1.0
* Updated linter to `package:lints`

View file

@ -94,8 +94,8 @@ class MockHttpHeaders extends HttpHeaders {
}
@override
void forEach(void Function(String name, List<String> values) f) {
_data.forEach(f);
void forEach(void Function(String name, List<String> values) action) {
_data.forEach(action);
}
@override

View file

@ -40,8 +40,8 @@ class MockHttpSession extends MapBase implements HttpSession {
}
@override
void forEach(void Function(dynamic, dynamic) f) {
_data.forEach(f);
void forEach(void Function(dynamic, dynamic) action) {
_data.forEach(action);
}
@override

View file

@ -1,10 +1,10 @@
name: angel3_mock_request
version: 2.1.0
version: 6.0.0
description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dependencies:
charcode: ^1.2.0
dev_dependencies:
@ -12,3 +12,6 @@ dev_dependencies:
http: ^0.13.2
test: ^1.17.4
lints: ^1.0.0
dependency_overrides:
angel3_framework:
path: ../framework

View file

@ -1,5 +1,17 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.0.0
* No release. Skipped
## 3.1.1
* Removed `error`

View file

@ -1,9 +1,9 @@
name: angel3_model
version: 3.1.1
version: 6.0.0
description: Angel3 basic data model class, no longer with the added weight of the whole framework.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/model
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dev_dependencies:
lints: ^1.0.0

View file

@ -1,5 +1,9 @@
# Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.2.0
* Updated `package:build_runner`

View file

@ -101,9 +101,9 @@ Supports both hashed routes and pushState. The `BrowserRouter` interface exposes
To prevent this for a given anchor, do any of the following:
* Do not provide an `href`
* Provide a `download` or `target` attribute on the element
* Set `rel="external"`
- Do not provide an `href`
- Provide a `download` or `target` attribute on the element
- Set `rel="external"`
## Route State

View file

@ -4,10 +4,10 @@ import 'router.dart';
class MiddlewarePipeline<T> {
/// All the possible routes that matched the given path.
final Iterable<RoutingResult<T>> routingResults;
final List<T?> _handlers = [];
final List<T> _handlers = [];
/// An ordered list of every handler delegated to handle this request.
List<T?> get handlers {
List<T> get handlers {
/*
if (_handlers != null) return _handlers;
final handlers = <T>[];

View file

@ -101,7 +101,7 @@ class Router<T> {
for (var route in routes) {
if (route is! SymlinkRoute<T>) {
router._routes.add(route.clone());
} else if (route is SymlinkRoute<T>) {
} else {
final newRouter = route.router.clone();
newMounted[route.path] = newRouter;
final symlink = SymlinkRoute<T>(route.path, newRouter);
@ -141,7 +141,7 @@ class Router<T> {
indent();
buf.write('- ');
if (route is! SymlinkRoute) buf.write('${route.method} ');
buf.write('${route.path.isNotEmpty ? route.path : '/'}');
buf.write(route.path.isNotEmpty ? route.path : '/');
if (route is SymlinkRoute<T>) {
buf.writeln();

View file

@ -1,10 +1,10 @@
name: angel3_route
version: 5.2.0
description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel framework, but can be used in Flutter and on the Web.
version: 6.0.0
description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel3 framework, but can be used in Flutter and on the Web.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/route
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dependencies:
belatuk_combinator: ^3.0.0
string_scanner: ^1.1.0
@ -13,5 +13,5 @@ dev_dependencies:
build_runner: ^2.1.2
build_web_compilers: ^3.2.1
http: ^0.13.3
test: ^1.17.5
test: ^1.20.0
lints: ^1.0.0