Fixed http exception error
This commit is contained in:
parent
2ed19c08cc
commit
1717897b9a
29 changed files with 61 additions and 39 deletions
|
@ -54,6 +54,7 @@ For more details, checkout [Project Status](https://github.com/dukefirehawk/ange
|
|||
* Added default logger to generate standardised logging messages
|
||||
* Added `melos` support
|
||||
* Removed deprecated API
|
||||
* [**Breaking**] `error` for `AngelHttpException` is no longer mandatory
|
||||
|
||||
## Installation and Setup
|
||||
|
||||
|
|
5
TODO.md
5
TODO.md
|
@ -5,13 +5,10 @@
|
|||
* Update examples
|
||||
* Update User Guide
|
||||
* Fix bugs
|
||||
* `angel3_oauth2` failed test cases
|
||||
* `angel3_proxy` failed test cases
|
||||
* `angel3_orm_mysql`
|
||||
|
||||
## Long Term Goal
|
||||
|
||||
* Refactor Angel3 architecture for performance and security
|
||||
* Better logging for error messages
|
||||
* Improve exception and error handling
|
||||
* Improve ORM features
|
||||
* Improve performances
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* Fixed analyze error
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
|
|
|
@ -41,7 +41,7 @@ class CorsOptions {
|
|||
/// - `bool Function(String)` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and returns a [bool].
|
||||
///
|
||||
/// Default: `'*'`
|
||||
final origin;
|
||||
final dynamic origin;
|
||||
|
||||
/// If `false`, then the [cors] handler will terminate the response after performing its logic.
|
||||
///
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_cors
|
||||
version: 6.0.0
|
||||
version: 6.0.1
|
||||
description: Angel3 CORS middleware. Ported from expressjs/cors to Angel3 framework.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/cors
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
|
||||
# Change Log
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* Updated README
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
* Removed `error`
|
||||
* [**Breaking**] `error` for `AngelHttpException` is no longer mandatory
|
||||
|
||||
## 5.0.0
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class AngelHttpException implements Exception {
|
|||
/// A list of errors that occurred when this exception was thrown.
|
||||
final List<String> errors = [];
|
||||
|
||||
/// The cause of this exception.
|
||||
/// The error throw by exception.
|
||||
dynamic error;
|
||||
|
||||
/// The cause of this exception.
|
||||
|
@ -28,6 +28,7 @@ class AngelHttpException implements Exception {
|
|||
{this.message = '500 Internal Server Error',
|
||||
this.stackTrace,
|
||||
this.statusCode = 500,
|
||||
this.error,
|
||||
List<String> errors = const []}) {
|
||||
this.errors.addAll(errors);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_http_exception
|
||||
version: 6.0.0
|
||||
version: 6.0.1
|
||||
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
|
||||
|
|
|
@ -248,8 +248,7 @@ class CodeActionContext {
|
|||
|
||||
final List<Diagnostic>? diagnostics;
|
||||
|
||||
Map toJson() =>
|
||||
{'diagnostics': diagnostics?.map((v) => v.toJson()).toList()};
|
||||
Map toJson() => {'diagnostics': diagnostics?.map((v) => v.toJson()).toList()};
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = 698635161;
|
||||
|
@ -966,10 +965,8 @@ class Diagnostics {
|
|||
|
||||
final String? uri;
|
||||
|
||||
Map toJson() => {
|
||||
'diagnostics': diagnostics?.map((v) => v.toJson()).toList(),
|
||||
'uri': uri
|
||||
};
|
||||
Map toJson() =>
|
||||
{'diagnostics': diagnostics?.map((v) => v.toJson()).toList(), 'uri': uri};
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = 133599092;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* Fixed AngelHttpException error
|
||||
* [Breaking] Renamed `error` to `authError` for `AuthorizationException`
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
|
|
|
@ -5,9 +5,12 @@ class AuthorizationException extends AngelHttpException {
|
|||
final ErrorResponse errorResponse;
|
||||
|
||||
AuthorizationException(this.errorResponse,
|
||||
{StackTrace? stackTrace, int? statusCode, error})
|
||||
: super(error ?? errorResponse,
|
||||
stackTrace: stackTrace, message: '', statusCode: statusCode ?? 400);
|
||||
{StackTrace? stackTrace, int? statusCode, dynamic error})
|
||||
: super(
|
||||
stackTrace: stackTrace,
|
||||
message: '',
|
||||
//error: error,
|
||||
statusCode: statusCode ?? 400);
|
||||
|
||||
@override
|
||||
Map toJson() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_oauth2
|
||||
version: 6.0.0
|
||||
version: 6.0.1
|
||||
description: A class containing handlers that can be used within Angel to build a spec-compliant OAuth 2.0 server.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/oauth2
|
||||
|
|
|
@ -19,7 +19,7 @@ void main() {
|
|||
setUp(() async {
|
||||
app = Angel();
|
||||
app.configuration['properties'] = app.configuration;
|
||||
app.container!.registerSingleton(AuthCodes());
|
||||
app.container.registerSingleton(AuthCodes());
|
||||
|
||||
var server = _Server();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ void main() {
|
|||
|
||||
setUp(() async {
|
||||
app = Angel();
|
||||
app.container!.registerSingleton(AuthCodes());
|
||||
app.container.registerSingleton(AuthCodes());
|
||||
|
||||
var server = _Server();
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* Fixed exception errors
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
|
|
|
@ -116,7 +116,7 @@ class Proxy {
|
|||
scheduleMicrotask(() => remote.pipe(local));
|
||||
return false;
|
||||
} catch (e, st) {
|
||||
throw AngelHttpException(e,
|
||||
throw AngelHttpException(
|
||||
message: 'Could not connect WebSocket', stackTrace: st);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,6 @@ class Proxy {
|
|||
if (recoverFromDead) return true;
|
||||
|
||||
throw AngelHttpException(
|
||||
e,
|
||||
stackTrace: st,
|
||||
statusCode: 504,
|
||||
message:
|
||||
|
@ -189,7 +188,6 @@ class Proxy {
|
|||
if (recoverFromDead) return true;
|
||||
|
||||
throw AngelHttpException(
|
||||
e,
|
||||
stackTrace: st,
|
||||
statusCode: 504,
|
||||
message: 'Host "$uri" returned a malformed content-type',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_proxy
|
||||
version: 6.0.0
|
||||
version: 6.0.1
|
||||
description: Angel middleware to forward requests to another server (i.e. pub serve).
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/proxy
|
||||
|
|
|
@ -12,7 +12,7 @@ Future<HttpServer> startTestServer() {
|
|||
app.get('/foo/bar', (req, res) => res.write('baz'));
|
||||
app.post('/body', (RequestContext req, res) async {
|
||||
var body = await req.parseBody().then((_) => req.bodyAsMap);
|
||||
app.logger!.info('Body: $body');
|
||||
app.logger.info('Body: $body');
|
||||
return body;
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ import 'package:angel3_route/angel3_route.dart';
|
|||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
final router = Router()..get('/hello', '')..get('/user/:id', '');
|
||||
final router = Router()
|
||||
..get('/hello', '')
|
||||
..get('/user/:id', '');
|
||||
|
||||
router.group('/book/:id', (router) {
|
||||
router.get('/reviews', '');
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 6.0.1
|
||||
|
||||
* Fixed AngelHttpException error
|
||||
|
||||
## 6.0.0
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
|
|
|
@ -38,7 +38,7 @@ void main() async {
|
|||
// here we will use it to log invalid cookies.
|
||||
app.get('/cookies', (req, res) {
|
||||
var verifiedCookies = signer.readCookies(req, onInvalidCookie: (cookie) {
|
||||
app.logger!.warning('Invalid cookie: $cookie');
|
||||
app.logger.warning('Invalid cookie: $cookie');
|
||||
});
|
||||
res.writeln('${verifiedCookies.length} verified cookie(s)');
|
||||
res.writeln('${req.cookies.length} total unverified cookie(s)');
|
||||
|
|
|
@ -85,7 +85,7 @@ abstract class RateLimiter<User> {
|
|||
RateLimitingWindow<User> window, DateTime currentTime) {
|
||||
var retryAfter = window.resetTime!.difference(currentTime);
|
||||
res.headers['retry-after'] = retryAfter.inSeconds.toString();
|
||||
throw AngelHttpException(null, message: errorMessage, statusCode: 429);
|
||||
throw AngelHttpException(message: errorMessage, statusCode: 429);
|
||||
}
|
||||
|
||||
/// A request middleware that returns `true` if the user has not yet
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_security
|
||||
version: 6.0.0
|
||||
version: 6.0.1
|
||||
description: Angel3 infrastructure for improving security, rate limiting, and more
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/security
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 6.0.0-beta.2
|
||||
|
||||
* Fixed AngelHttpException error
|
||||
|
||||
## 6.0.0-beta.1
|
||||
|
||||
* Updated to SDK 2.16.x
|
||||
|
|
|
@ -48,7 +48,7 @@ Future<shelf.Request> convertRequest(RequestContext req, ResponseContext res,
|
|||
hijack(ctrl.foreign);
|
||||
} catch (e, st) {
|
||||
app?.logger
|
||||
?.severe('An error occurred while hijacking a shelf request', e, st);
|
||||
.severe('An error occurred while hijacking a shelf request', e, st);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@ RequestHandler embedShelf(shelf.Handler handler,
|
|||
handlerPath: handlerPath, context: context);
|
||||
try {
|
||||
var result = await handler(shelfRequest);
|
||||
if (result is! shelf.Response) return result;
|
||||
if (throwOnNullResponse == true) {
|
||||
throw AngelHttpException('Internal Server Error');
|
||||
throw AngelHttpException(message: 'Internal Server Error');
|
||||
}
|
||||
await mergeShelfResponse(result, res);
|
||||
return false;
|
||||
|
|
|
@ -6,9 +6,8 @@ import 'package:shelf/shelf.dart';
|
|||
import 'shelf_request.dart';
|
||||
import 'shelf_response.dart';
|
||||
|
||||
// TODO: To be reviewed
|
||||
Future<Stream<Request>> process(dynamic param1, int param2) {
|
||||
return Future.value();
|
||||
return Future.value(Stream.empty());
|
||||
}
|
||||
|
||||
class AngelShelf extends Driver<shelf.Request, ShelfResponseContext?,
|
||||
|
@ -106,7 +105,7 @@ class AngelShelf extends Driver<shelf.Request, ShelfResponseContext?,
|
|||
var path = request.url.path.replaceAll(_straySlashes, '');
|
||||
if (path.isEmpty) path = '/';
|
||||
var rq =
|
||||
ShelfRequestContext(app, app.container!.createChild(), request, path);
|
||||
ShelfRequestContext(app, app.container.createChild(), request, path);
|
||||
return Future.value(rq);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_shelf
|
||||
version: 6.0.0-beta.1
|
||||
version: 6.0.0-beta.2
|
||||
description: Shelf interop with Angel3. Use this to wrap existing server code.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/shelf
|
||||
|
|
Loading…
Reference in a new issue