update(angel3): rebranding angel3 framework package

This commit is contained in:
Patrick Stewart 2024-09-22 21:39:29 -07:00
parent 3b83e34dcc
commit 8347f74c40
60 changed files with 260 additions and 255 deletions

View file

@ -1,4 +1,4 @@
library angel3_container; library platform_container;
export 'src/container.dart'; export 'src/container.dart';
export 'src/empty/empty.dart'; export 'src/empty/empty.dart';

View file

@ -2,7 +2,7 @@ import '../reflector.dart';
/// A [Reflector] implementation that performs simple [Map] lookups. /// A [Reflector] implementation that performs simple [Map] lookups.
/// ///
/// `package:angel_container_generator` uses this to create reflectors from analysis metadata. /// `package:platform_container_generator` uses this to create reflectors from analysis metadata.
class StaticReflector extends Reflector { class StaticReflector extends Reflector {
final Map<Symbol, String> names; final Map<Symbol, String> names;
final Map<Type, ReflectedType> types; final Map<Type, ReflectedType> types;

View file

@ -8,8 +8,8 @@ void main() async {
Logger.root.onRecord.listen(print); Logger.root.onRecord.listen(print);
// Create our server. // Create our server.
var app = Angel(logger: Logger('angel'), reflector: MirrorsReflector()); var app = Protevus(logger: Logger('angel'), reflector: MirrorsReflector());
var http = AngelHttp(app); var http = ProtevusHttp(app);
await app.mountController<ArtistsController>(); await app.mountController<ArtistsController>();

View file

@ -6,7 +6,7 @@ import 'package:platform_framework/http.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
void main() async { void main() async {
var app = Angel(reflector: MirrorsReflector()) var app = Protevus(reflector: MirrorsReflector())
..logger = (Logger('angel') ..logger = (Logger('angel')
..onRecord.listen((rec) { ..onRecord.listen((rec) {
print(rec); print(rec);
@ -18,7 +18,7 @@ void main() async {
app.fallback( app.fallback(
(req, res) => Future.error('Throwing just because I feel like!')); (req, res) => Future.error('Throwing just because I feel like!'));
var http = AngelHttp(app); var http = ProtevusHttp(app);
HttpServer? server = await http.startServer('127.0.0.1', 3000); HttpServer? server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}'; var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url'); print('Listening at $url');

View file

@ -3,14 +3,14 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:platform_framework/http.dart'; import 'package:platform_framework/http.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
Future<void> apiConfigurer(Angel app) async { Future<void> apiConfigurer(Protevus app) async {
app.get('/', (req, res) => 'Hello, API!'); app.get('/', (req, res) => 'Hello, API!');
app.fallback((req, res) { app.fallback((req, res) {
return 'fallback on ${req.uri} (within the API)'; return 'fallback on ${req.uri} (within the API)';
}); });
} }
Future<void> frontendConfigurer(Angel app) async { Future<void> frontendConfigurer(Protevus app) async {
app.fallback((req, res) => '(usually an index page would be shown here.)'); app.fallback((req, res) => '(usually an index page would be shown here.)');
} }
@ -19,8 +19,8 @@ void main() async {
hierarchicalLoggingEnabled = true; hierarchicalLoggingEnabled = true;
//Logger.root.onRecord.listen(prettyLog); //Logger.root.onRecord.listen(prettyLog);
var app = Angel(logger: Logger('angel')); var app = Protevus(logger: Logger('angel'));
var http = AngelHttp(app); var http = ProtevusHttp(app);
var multiHost = HostnameRouter.configure({ var multiHost = HostnameRouter.configure({
'api.localhost:3000': apiConfigurer, 'api.localhost:3000': apiConfigurer,
'localhost:3000': frontendConfigurer, 'localhost:3000': frontendConfigurer,

View file

@ -6,7 +6,7 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
void main() async { void main() async {
var app = Angel(); var app = Protevus();
app.logger = Logger('angel') app.logger = Logger('angel')
..onRecord.listen((rec) { ..onRecord.listen((rec) {
print(rec); print(rec);
@ -35,10 +35,10 @@ void main() async {
st); st);
} }
var http1 = AngelHttp(app); var http1 = ProtevusHttp(app);
var http2 = AngelHttp2(app, ctx); var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp` // HTTP/1.x requests will fallback to `ProtevusHttp`
http2.onHttp1.listen(http1.handleRequest); http2.onHttp1.listen(http1.handleRequest);
var server = await http2.startServer('127.0.0.1', 3000); var server = await http2.startServer('127.0.0.1', 3000);

View file

@ -6,7 +6,7 @@ import 'package:logging/logging.dart';
import 'common.dart'; import 'common.dart';
void main() async { void main() async {
var app = Angel() var app = Protevus()
..encoders.addAll({ ..encoders.addAll({
'gzip': gzip.encoder, 'gzip': gzip.encoder,
'deflate': zlib.encoder, 'deflate': zlib.encoder,
@ -32,10 +32,10 @@ void main() async {
); );
} }
var http1 = AngelHttp(app); var http1 = ProtevusHttp(app);
var http2 = AngelHttp2(app, ctx); var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp` // HTTP/1.x requests will fallback to `ProtevusHttp`
http2.onHttp1.listen(http1.handleRequest); http2.onHttp1.listen(http1.handleRequest);
await http2.startServer('127.0.0.1', 3000); await http2.startServer('127.0.0.1', 3000);

View file

@ -7,7 +7,7 @@ window.onload = function() {
$app.appendChild($h1); $app.appendChild($h1);
$app.appendChild($button); $app.appendChild($button);
$h1.textContent = '~Angel HTTP/2 server push~'; $h1.textContent = '~Protevus HTTP/2 server push~';
$button.textContent = 'Change color'; $button.textContent = 'Change color';
$button.onclick = function() { $button.onclick = function() {

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Angel HTTP/2</title> <title>Protevus HTTP/2</title>
<style> <style>
input:not([type="submit"]) { input:not([type="submit"]) {
margin-bottom: 2em; margin-bottom: 2em;

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Angel HTTP/2</title> <title>Protevus HTTP/2</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body> <body>

View file

@ -6,7 +6,7 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
void main() async { void main() async {
var app = Angel(); var app = Protevus();
app.logger = Logger('angel') app.logger = Logger('angel')
..onRecord.listen((rec) { ..onRecord.listen((rec) {
print(rec); print(rec);
@ -51,10 +51,10 @@ void main() async {
st); st);
} }
var http1 = AngelHttp(app); var http1 = ProtevusHttp(app);
var http2 = AngelHttp2(app, ctx); var http2 = ProtevusHttp2(app, ctx);
// HTTP/1.x requests will fallback to `AngelHttp` // HTTP/1.x requests will fallback to `ProtevusHttp`
http2.onHttp1.listen(http1.handleRequest); http2.onHttp1.listen(http1.handleRequest);
var server = await http2.startServer('127.0.0.1', 3000); var server = await http2.startServer('127.0.0.1', 3000);

View file

@ -26,14 +26,14 @@ void main() async {
serverMain(null); serverMain(null);
print('Angel listening at http://localhost:3000'); print('Protevus listening at http://localhost:3000');
await c.future; await c.future;
} }
void serverMain(_) async { void serverMain(_) async {
var app = Angel(); var app = Protevus();
var http = var http =
AngelHttp.custom(app, startShared, useZone: false); // Run a cluster ProtevusHttp.custom(app, startShared, useZone: false); // Run a cluster
app.get('/', (req, res) { app.get('/', (req, res) {
return res.serialize({ return res.serialize({

View file

@ -8,13 +8,13 @@ void main() async {
//Logger.root.onRecord.listen(prettyLog); //Logger.root.onRecord.listen(prettyLog);
// Create our server. // Create our server.
var app = Angel( var app = Protevus(
logger: Logger('angel'), logger: Logger('angel'),
reflector: MirrorsReflector(), reflector: MirrorsReflector(),
); );
// Index route. Returns JSON. // Index route. Returns JSON.
app.get('/', (req, res) => 'Welcome to Angel!'); app.get('/', (req, res) => 'Welcome to Protevus!');
// Accepts a URL like /greet/foo or /greet/bob. // Accepts a URL like /greet/foo or /greet/bob.
app.get( app.get(
@ -46,11 +46,11 @@ void main() async {
); );
}); });
var http = AngelHttp(app); var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000); var server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}'; var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url'); print('Listening at $url');
print('Visit these pages to see Angel in action:'); print('Visit these pages to see Protevus in action:');
print('* $url/greet/bob'); print('* $url/greet/bob');
print('* $url/greet/?name=emoji'); print('* $url/greet/?name=emoji');
print('* $url/greet/?name=jack'); print('* $url/greet/?name=jack');

View file

@ -8,7 +8,7 @@ void main() async {
Logger.root.onRecord.listen(print); Logger.root.onRecord.listen(print);
// Create our server. // Create our server.
var app = Angel( var app = Protevus(
logger: Logger('angel'), logger: Logger('angel'),
reflector: MirrorsReflector(), reflector: MirrorsReflector(),
); );
@ -16,7 +16,7 @@ void main() async {
// Create a RESTful service that manages an in-memory collection. // Create a RESTful service that manages an in-memory collection.
app.use('/api/todos', MapService()); app.use('/api/todos', MapService());
var http = AngelHttp(app); var http = ProtevusHttp(app);
await http.startServer('127.0.0.1', 0); await http.startServer('127.0.0.1', 0);
print('Listening at ${http.uri}'); print('Listening at ${http.uri}');
} }

View file

@ -2,8 +2,8 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:platform_framework/http.dart'; import 'package:platform_framework/http.dart';
void main() async { void main() async {
var app = Angel(); var app = Protevus();
var http = AngelHttp(app); var http = ProtevusHttp(app);
app.fallback((req, res) { app.fallback((req, res) {
res.statusCode = 304; res.statusCode = 304;

View file

@ -3,7 +3,7 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:platform_framework/http.dart'; import 'package:platform_framework/http.dart';
void main() async { void main() async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
app.viewGenerator = (name, [data]) async => app.viewGenerator = (name, [data]) async =>
'View generator invoked with name $name and data: $data'; 'View generator invoked with name $name and data: $data';
@ -11,7 +11,7 @@ void main() async {
// Index route. Returns JSON. // Index route. Returns JSON.
app.get('/', (req, res) => res.render('index', {'foo': 'bar'})); app.get('/', (req, res) => res.render('index', {'foo': 'bar'}));
var http = AngelHttp(app); var http = ProtevusHttp(app);
var server = await http.startServer('127.0.0.1', 3000); var server = await http.startServer('127.0.0.1', 3000);
var url = 'http://${server.address.address}:${server.port}'; var url = 'http://${server.address.address}:${server.port}';
print('Listening at $url'); print('Listening at $url');

View file

@ -9,12 +9,12 @@ import '../core/core.dart';
/// Supports grouping routes with shared functionality. /// Supports grouping routes with shared functionality.
class Controller { class Controller {
Angel? _app; Protevus? _app;
/// The [Angel] application powering this controller. /// The [Protevus] application powering this controller.
Angel get app { Protevus get app {
if (_app == null) { if (_app == null) {
throw ArgumentError("Angel is not instantiated."); throw ArgumentError("Protevus is not instantiated.");
} }
return _app!; return _app!;
@ -38,7 +38,7 @@ class Controller {
/// Applies routes, DI, and other configuration to an [app]. /// Applies routes, DI, and other configuration to an [app].
@mustCallSuper @mustCallSuper
Future<void> configureServer(Angel app) async { Future<void> configureServer(Protevus app) async {
_app = app; _app = app;
if (injectSingleton != false) { if (injectSingleton != false) {

View file

@ -8,16 +8,16 @@ import 'package:stack_trace/stack_trace.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'core.dart'; import 'core.dart';
/// Base driver class for Angel implementations. /// Base driver class for Protevus implementations.
/// ///
/// Powers both AngelHttp and AngelHttp2. /// Powers both ProtevusHttp and ProtevusHttp2.
abstract class Driver< abstract class Driver<
Request, Request,
Response, Response,
Server extends Stream<Request>, Server extends Stream<Request>,
RequestContextType extends RequestContext, RequestContextType extends RequestContext,
ResponseContextType extends ResponseContext> { ResponseContextType extends ResponseContext> {
final Angel app; final Protevus app;
final bool useZone; final bool useZone;
bool _closed = false; bool _closed = false;
@ -383,7 +383,7 @@ abstract class Driver<
MiddlewarePipelineIterator<RequestHandler> it, MiddlewarePipelineIterator<RequestHandler> it,
RequestContextType req, RequestContextType req,
ResponseContextType res, ResponseContextType res,
Angel app) async { Protevus app) async {
var broken = false; var broken = false;
while (it.moveNext()) { while (it.moveNext()) {
var current = it.current.handlers.iterator; var current = it.current.handlers.iterator;

View file

@ -1,19 +1,19 @@
import 'dart:io'; import 'dart:io';
/// A constant instance of [AngelEnv]. /// A constant instance of [ProtevusEnv].
const AngelEnvironment angelEnv = AngelEnvironment(); const ProtevusEnvironment protevusEnv = ProtevusEnvironment();
/// Queries the environment's `ANGEL_ENV` value. /// Queries the environment's `ANGEL_ENV` value.
class AngelEnvironment { class ProtevusEnvironment {
final String? _customValue; final String? _customValue;
/// You can optionally provide a custom value, in order to override the system's /// You can optionally provide a custom value, in order to override the system's
/// value. /// value.
const AngelEnvironment([this._customValue]); const ProtevusEnvironment([this._customValue]);
/// Returns the value of the `ANGEL_ENV` variable; defaults to `'development'`. /// Returns the value of the `ANGEL_ENV` variable; defaults to `'development'`.
String get value => String get value =>
(_customValue ?? Platform.environment['ANGEL_ENV'] ?? 'development') (_customValue ?? Platform.environment['PROTEVUS_ENV'] ?? 'development')
.toLowerCase(); .toLowerCase();
/// Returns whether the [value] is `'development'`. /// Returns whether the [value] is `'development'`.

View file

@ -98,7 +98,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
} }
/// Adds hooks to this instance. /// Adds hooks to this instance.
void addHooks(Angel app) { void addHooks(Protevus app) {
var hooks = getAnnotation<Hooks>(inner, app.container.reflector); var hooks = getAnnotation<Hooks>(inner, app.container.reflector);
var before = <HookedServiceEventListener<Id, Data, T>>[]; var before = <HookedServiceEventListener<Id, Data, T>>[];
var after = <HookedServiceEventListener<Id, Data, T>>[]; var after = <HookedServiceEventListener<Id, Data, T>>[];

View file

@ -24,13 +24,13 @@ import 'server.dart';
/// * `example.*` -> `/example\./[^$]*` /// * `example.*` -> `/example\./[^$]*`
/// * `example.+` -> `/example\./[^$]+` /// * `example.+` -> `/example\./[^$]+`
class HostnameRouter { class HostnameRouter {
final Map<Pattern, Angel> _apps = {}; final Map<Pattern, Protevus> _apps = {};
final Map<Pattern, FutureOr<Angel> Function()> _creators = {}; final Map<Pattern, FutureOr<Protevus> Function()> _creators = {};
final List<Pattern> _patterns = []; final List<Pattern> _patterns = [];
HostnameRouter( HostnameRouter(
{Map<Pattern, Angel> apps = const {}, {Map<Pattern, Protevus> apps = const {},
Map<Pattern, FutureOr<Angel> Function()> creators = const {}}) { Map<Pattern, FutureOr<Protevus> Function()> creators = const {}}) {
Map<Pattern, V> parseMap<V>(Map<Pattern, V> map) { Map<Pattern, V> parseMap<V>(Map<Pattern, V> map) {
return map.map((p, c) { return map.map((p, c) {
Pattern pp; Pattern pp;
@ -55,16 +55,16 @@ class HostnameRouter {
} }
factory HostnameRouter.configure( factory HostnameRouter.configure(
Map<Pattern, FutureOr<void> Function(Angel)> configurers, Map<Pattern, FutureOr<void> Function(Protevus)> configurers,
{Reflector reflector = const EmptyReflector(), {Reflector reflector = const EmptyReflector(),
AngelEnvironment environment = angelEnv, ProtevusEnvironment environment = protevusEnv,
Logger? logger, Logger? logger,
bool allowMethodOverrides = true, bool allowMethodOverrides = true,
FutureOr<String> Function(dynamic)? serializer, FutureOr<String> Function(dynamic)? serializer,
ViewGenerator? viewGenerator}) { ViewGenerator? viewGenerator}) {
var creators = configurers.map((p, c) { var creators = configurers.map((p, c) {
return MapEntry(p, () async { return MapEntry(p, () async {
var app = Angel( var app = Protevus(
reflector: reflector, reflector: reflector,
environment: environment, environment: environment,
logger: logger, logger: logger,

View file

@ -1,4 +1,4 @@
library angel_framework.http.request_context; library Protevus_framework.http.request_context;
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
@ -18,13 +18,13 @@ import 'package:logging/logging.dart';
import 'metadata.dart'; import 'metadata.dart';
import 'response_context.dart'; import 'response_context.dart';
import 'routable.dart'; import 'routable.dart';
import 'server.dart' show Angel; import 'server.dart' show Protevus;
part 'injection.dart'; part 'injection.dart';
/// A convenience wrapper around an incoming [RawRequest]. /// A convenience wrapper around an incoming [RawRequest].
abstract class RequestContext<RawRequest> { abstract class RequestContext<RawRequest> {
/// Similar to [Angel.shutdownHooks], allows for logic to be executed /// Similar to [Protevus.shutdownHooks], allows for logic to be executed
/// when a [RequestContext] is done being processed. /// when a [RequestContext] is done being processed.
final _log = Logger('RequestContext'); final _log = Logger('RequestContext');
@ -46,8 +46,8 @@ abstract class RequestContext<RawRequest> {
/// Additional params to be passed to services. /// Additional params to be passed to services.
final Map<String, dynamic> serviceParams = {}; final Map<String, dynamic> serviceParams = {};
/// The [Angel] instance that is responding to this request. /// The [Protevus] instance that is responding to this request.
Angel? app; Protevus? app;
/// Any cookies sent with this request. /// Any cookies sent with this request.
List<Cookie> get cookies => <Cookie>[]; List<Cookie> get cookies => <Cookie>[];
@ -131,7 +131,7 @@ abstract class RequestContext<RawRequest> {
/// This setter allows you to explicitly set the request body **exactly once**. /// This setter allows you to explicitly set the request body **exactly once**.
/// ///
/// Use this if the format of the body is not natively parsed by Angel. /// Use this if the format of the body is not natively parsed by Protevus.
set bodyAsMap(Map<String, dynamic>? value) => bodyAsObject = value; set bodyAsMap(Map<String, dynamic>? value) => bodyAsObject = value;
/// Returns a *mutable* [List] parsed from the request [body]. /// Returns a *mutable* [List] parsed from the request [body].
@ -151,7 +151,7 @@ abstract class RequestContext<RawRequest> {
/// This setter allows you to explicitly set the request body **exactly once**. /// This setter allows you to explicitly set the request body **exactly once**.
/// ///
/// Use this if the format of the body is not natively parsed by Angel. /// Use this if the format of the body is not natively parsed by Protevus.
set bodyAsList(List? value) => bodyAsObject = value; set bodyAsList(List? value) => bodyAsObject = value;
/// Returns the parsed request body, whatever it may be (typically a [Map] or [List]). /// Returns the parsed request body, whatever it may be (typically a [Map] or [List]).
@ -167,7 +167,7 @@ abstract class RequestContext<RawRequest> {
/// This setter allows you to explicitly set the request body **exactly once**. /// This setter allows you to explicitly set the request body **exactly once**.
/// ///
/// Use this if the format of the body is not natively parsed by Angel. /// Use this if the format of the body is not natively parsed by Protevus.
set bodyAsObject(value) { set bodyAsObject(value) {
if (_bodyObject != null) { if (_bodyObject != null) {
throw StateError( throw StateError(

View file

@ -13,7 +13,7 @@ import 'package:mime/mime.dart';
import 'controller.dart'; import 'controller.dart';
import 'request_context.dart'; import 'request_context.dart';
import 'server.dart' show Angel; import 'server.dart' show Protevus;
final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
@ -22,15 +22,15 @@ abstract class ResponseContext<RawResponse>
implements StreamConsumer<List<int>>, StreamSink<List<int>>, StringSink { implements StreamConsumer<List<int>>, StreamSink<List<int>>, StringSink {
final Map properties = {}; final Map properties = {};
final CaseInsensitiveMap<String> _headers = CaseInsensitiveMap<String>.from( final CaseInsensitiveMap<String> _headers = CaseInsensitiveMap<String>.from(
{'content-type': 'text/plain', 'server': 'Angel3'}); {'content-type': 'text/plain', 'server': 'Protevus3'});
//final log = Logger('ResponseContext'); //final log = Logger('ResponseContext');
Completer? _done; Completer? _done;
int _statusCode = 200; int _statusCode = 200;
/// The [Angel] instance that is sending a response. /// The [Protevus] instance that is sending a response.
Angel? app; Protevus? app;
/// Is `Transfer-Encoding` chunked? /// Is `Transfer-Encoding` chunked?
bool? chunked; bool? chunked;
@ -84,9 +84,9 @@ abstract class ResponseContext<RawResponse>
} }
} }
/// Returns `true` if the response is still available for processing by Angel. /// Returns `true` if the response is still available for processing by Protevus.
/// ///
/// If it is `false`, then Angel will stop executing handlers, and will only run /// If it is `false`, then Protevus will stop executing handlers, and will only run
/// response finalizers if the response [isBuffered]. /// response finalizers if the response [isBuffered].
bool get isOpen; bool get isOpen;
@ -99,7 +99,7 @@ abstract class ResponseContext<RawResponse>
/// The underlying [RawResponse] under this instance. /// The underlying [RawResponse] under this instance.
RawResponse get rawResponse; RawResponse get rawResponse;
/// Signals Angel that the response is being held alive deliberately, and that the framework should not automatically close it. /// Signals Protevus that the response is being held alive deliberately, and that the framework should not automatically close it.
/// ///
/// This is mostly used in situations like WebSocket handlers, where the connection should remain /// This is mostly used in situations like WebSocket handlers, where the connection should remain
/// open indefinitely. /// open indefinitely.

View file

@ -21,18 +21,18 @@ import 'service.dart';
//final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); //final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
/// A function that configures an [Angel] server. /// A function that configures an [Protevus] server.
typedef AngelConfigurer = FutureOr<void> Function(Angel app); typedef Configurer = FutureOr<void> Function(Protevus app);
/// A function that asynchronously generates a view from the given path and data. /// A function that asynchronously generates a view from the given path and data.
typedef ViewGenerator = FutureOr<String> Function(String path, typedef ViewGenerator = FutureOr<String> Function(String path,
[Map<String, dynamic>? data]); [Map<String, dynamic>? data]);
/// A function that handles error /// A function that handles error
typedef AngelErrorHandler = dynamic Function( typedef PlatformErrorHandler = dynamic Function(
HttpException e, RequestContext req, ResponseContext res); HttpException e, RequestContext req, ResponseContext res);
/// The default error handler for [Angel] server /// The default error handler for [Protevus] server
Future<bool> _defaultErrorHandler( Future<bool> _defaultErrorHandler(
HttpException e, RequestContext req, ResponseContext res) async { HttpException e, RequestContext req, ResponseContext res) async {
if (!req.accepts('text/html', strict: true) && if (!req.accepts('text/html', strict: true) &&
@ -78,18 +78,18 @@ Logger _defaultLogger() {
} }
/// A powerful real-time/REST/MVC server class. /// A powerful real-time/REST/MVC server class.
class Angel extends Routable { class Protevus extends Routable {
static Future<String> _noViewEngineConfigured(String view, [Map? data]) => static Future<String> _noViewEngineConfigured(String view, [Map? data]) =>
Future.value('No view engine has been configured yet.'); Future.value('No view engine has been configured yet.');
final List<Angel> _children = []; final List<Protevus> _children = [];
final Map< final Map<
String, String,
Tuple4<List, Map<String, dynamic>, ParseResult<RouteResult>, Tuple4<List, Map<String, dynamic>, ParseResult<RouteResult>,
MiddlewarePipeline>> handlerCache = HashMap(); MiddlewarePipeline>> handlerCache = HashMap();
Router<RequestHandler>? _flattened; Router<RequestHandler>? _flattened;
Angel? _parent; Protevus? _parent;
/// A global Map of converters that can transform responses bodies. /// A global Map of converters that can transform responses bodies.
final Map<String, Converter<List<int>, List<int>>> encoders = {}; final Map<String, Converter<List<int>, List<int>>> encoders = {};
@ -114,20 +114,20 @@ class Angel extends Routable {
bool allowMethodOverrides = true; bool allowMethodOverrides = true;
/// All child application mounted on this instance. /// All child application mounted on this instance.
List<Angel> get children => List<Angel>.unmodifiable(_children); List<Protevus> get children => List<Protevus>.unmodifiable(_children);
final Map<Pattern, Controller> _controllers = {}; final Map<Pattern, Controller> _controllers = {};
/// A set of [Controller] objects that have been loaded into the application. /// A set of [Controller] objects that have been loaded into the application.
Map<Pattern, Controller> get controllers => _controllers; Map<Pattern, Controller> get controllers => _controllers;
/// The [AngelEnvironment] in which the application is running. /// The [ProtevusEnvironment] in which the application is running.
/// ///
/// By default, it is automatically inferred. /// By default, it is automatically inferred.
final AngelEnvironment environment; final ProtevusEnvironment environment;
/// Returns the parent instance of this application, if any. /// Returns the parent instance of this application, if any.
Angel? get parent => _parent; Protevus? get parent => _parent;
/// Outputs diagnostics and debug messages. /// Outputs diagnostics and debug messages.
Logger _logger = _defaultLogger(); Logger _logger = _defaultLogger();
@ -145,12 +145,12 @@ class Angel extends Routable {
/// Plug-ins to be called right before server startup. /// Plug-ins to be called right before server startup.
/// ///
/// If the server is never started, they will never be called. /// If the server is never started, they will never be called.
final List<AngelConfigurer> startupHooks = []; final List<Configurer> startupHooks = [];
/// Plug-ins to be called right before server shutdown. /// Plug-ins to be called right before server shutdown.
/// ///
/// If the server is never [close]d, they will never be called. /// If the server is never [close]d, they will never be called.
final List<AngelConfigurer> shutdownHooks = []; final List<Configurer> shutdownHooks = [];
/// Always run before responses are sent. /// Always run before responses are sent.
/// ///
@ -163,7 +163,7 @@ class Angel extends Routable {
ViewGenerator? viewGenerator = _noViewEngineConfigured; ViewGenerator? viewGenerator = _noViewEngineConfigured;
/// The handler currently configured to run on [HttpException]s. /// The handler currently configured to run on [HttpException]s.
AngelErrorHandler errorHandler = _defaultErrorHandler; PlatformErrorHandler errorHandler = _defaultErrorHandler;
@override @override
Route<RequestHandler> addRoute( Route<RequestHandler> addRoute(
@ -189,7 +189,7 @@ class Angel extends Routable {
'This route will be ignored, and no requests will ever reach it.'); 'This route will be ignored, and no requests will ever reach it.');
} }
if (router is Angel) { if (router is Protevus) {
router._parent = this; router._parent = this;
_children.add(router); _children.add(router);
} }
@ -199,11 +199,11 @@ class Angel extends Routable {
/// Loads some base dependencies into the service container. /// Loads some base dependencies into the service container.
void bootstrapContainer() { void bootstrapContainer() {
if (runtimeType != Angel) { if (runtimeType != Protevus) {
container.registerSingleton(this); container.registerSingleton(this);
} }
container.registerSingleton<Angel>(this); container.registerSingleton<Protevus>(this);
container.registerSingleton<Routable>(this); container.registerSingleton<Routable>(this);
container.registerSingleton<Router>(this); container.registerSingleton<Router>(this);
} }
@ -311,7 +311,7 @@ class Angel extends Routable {
return null; return null;
} }
/// Runs several optimizations, *if* [angelEnv.isProduction] is `true`. /// Runs several optimizations, *if* [protevusEnv.isProduction] is `true`.
/// ///
/// * Preprocesses all dependency injection, and eliminates the burden of reflecting handlers /// * Preprocesses all dependency injection, and eliminates the burden of reflecting handlers
/// at run-time. /// at run-time.
@ -321,7 +321,7 @@ class Angel extends Routable {
void optimizeForProduction({bool force = false}) { void optimizeForProduction({bool force = false}) {
if (environment.isProduction || force == true) { if (environment.isProduction || force == true) {
_flattened ??= flatten(this); _flattened ??= flatten(this);
logger.info('Angel is running in production mode.'); logger.info('Protevus is running in production mode.');
} }
} }
@ -358,8 +358,8 @@ class Angel extends Routable {
// return closureMirror.apply(args).reflectee; // return closureMirror.apply(args).reflectee;
} }
/// Applies an [AngelConfigurer] to this instance. /// Applies an [Configurer] to this instance.
Future configure(AngelConfigurer configurer) { Future configure(Configurer configurer) {
return Future.sync(() => configurer(this)); return Future.sync(() => configurer(this));
} }
@ -396,10 +396,10 @@ class Angel extends Routable {
'For more, see the documentation:\n' 'For more, see the documentation:\n'
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection'; 'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
Angel( Protevus(
{Reflector reflector = {Reflector reflector =
const ThrowingReflector(errorMessage: _reflectionErrorMessage), const ThrowingReflector(errorMessage: _reflectionErrorMessage),
this.environment = angelEnv, this.environment = protevusEnv,
Logger? logger, Logger? logger,
this.allowMethodOverrides = true, this.allowMethodOverrides = true,
this.serializer, this.serializer,
@ -412,7 +412,7 @@ class Angel extends Routable {
if (reflector is EmptyReflector || reflector is ThrowingReflector) { if (reflector is EmptyReflector || reflector is ThrowingReflector) {
var msg = var msg =
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n$_reflectionInfo'; 'No `reflector` was passed to the Protevus constructor, so reflection will not be available.\n$_reflectionInfo';
this.logger.warning(msg); this.logger.warning(msg);
} }

View file

@ -67,17 +67,17 @@ class Service<Id, Data> extends Routable {
/// Handlers that must run to ensure this service's functionality. /// Handlers that must run to ensure this service's functionality.
List<RequestHandler> get bootstrappers => []; List<RequestHandler> get bootstrappers => [];
/// The [Angel] app powering this service. /// The [Protevus] app powering this service.
Angel? _app; Protevus? _app;
Angel get app { Protevus get app {
if (_app == null) { if (_app == null) {
throw ArgumentError("Angel is not initialized"); throw ArgumentError("Protevus is not initialized");
} }
return _app!; return _app!;
} }
set app(Angel angel) { set app(Protevus angel) {
_app = angel; _app = angel;
} }

View file

@ -17,8 +17,8 @@ final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
typedef ServerGeneratorType = Future<HttpServer> Function(dynamic, int); typedef ServerGeneratorType = Future<HttpServer> Function(dynamic, int);
/// Adapts `dart:io`'s [HttpServer] to serve Angel. /// Adapts `dart:io`'s [HttpServer] to serve Protevus.
class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer, class ProtevusHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
HttpRequestContext, HttpResponseContext> { HttpRequestContext, HttpResponseContext> {
@override @override
Uri get uri { Uri get uri {
@ -26,22 +26,23 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
scheme: 'http', host: server?.address.address, port: server?.port); scheme: 'http', host: server?.address.address, port: server?.port);
} }
AngelHttp._(super.app, super.serverGenerator, bool useZone) ProtevusHttp._(super.app, super.serverGenerator, bool useZone)
: super(useZone: useZone); : super(useZone: useZone);
factory AngelHttp(Angel app, {bool useZone = true}) { factory ProtevusHttp(Protevus app, {bool useZone = true}) {
return AngelHttp._(app, HttpServer.bind, useZone); return ProtevusHttp._(app, HttpServer.bind, useZone);
} }
/// An instance mounted on a server started by the [serverGenerator]. /// An instance mounted on a server started by the [serverGenerator].
factory AngelHttp.custom(Angel app, ServerGeneratorType serverGenerator, factory ProtevusHttp.custom(Protevus app, ServerGeneratorType serverGenerator,
{bool useZone = true, Map<String, String> headers = const {}}) { {bool useZone = true, Map<String, String> headers = const {}}) {
return AngelHttp._(app, serverGenerator, useZone); return ProtevusHttp._(app, serverGenerator, useZone);
} }
factory AngelHttp.fromSecurityContext(Angel app, SecurityContext context, factory ProtevusHttp.fromSecurityContext(
Protevus app, SecurityContext context,
{bool useZone = true}) { {bool useZone = true}) {
return AngelHttp._(app, (address, int port) { return ProtevusHttp._(app, (address, int port) {
return HttpServer.bindSecure(address, port, context); return HttpServer.bindSecure(address, port, context);
}, useZone); }, useZone);
} }
@ -51,8 +52,8 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
/// Provide paths to a certificate chain and server key (both .pem). /// Provide paths to a certificate chain and server key (both .pem).
/// If no password is provided, a random one will be generated upon running /// If no password is provided, a random one will be generated upon running
/// the server. /// the server.
factory AngelHttp.secure( factory ProtevusHttp.secure(
Angel app, String certificateChainPath, String serverKeyPath, Protevus app, String certificateChainPath, String serverKeyPath,
{String? password, bool useZone = true}) { {String? password, bool useZone = true}) {
var certificateChain = var certificateChain =
Platform.script.resolve(certificateChainPath).toFilePath(); Platform.script.resolve(certificateChainPath).toFilePath();
@ -61,7 +62,8 @@ class AngelHttp extends Driver<HttpRequest, HttpResponse, HttpServer,
serverContext.useCertificateChain(certificateChain, password: password); serverContext.useCertificateChain(certificateChain, password: password);
serverContext.usePrivateKey(serverKey, password: password); serverContext.usePrivateKey(serverKey, password: password);
return AngelHttp.fromSecurityContext(app, serverContext, useZone: useZone); return ProtevusHttp.fromSecurityContext(app, serverContext,
useZone: useZone);
} }
Future handleRequest(HttpRequest request) => Future handleRequest(HttpRequest request) =>

View file

@ -77,7 +77,7 @@ class HttpRequestContext extends RequestContext<HttpRequest?> {
/// Magically transforms an [HttpRequest] into a [RequestContext]. /// Magically transforms an [HttpRequest] into a [RequestContext].
static Future<HttpRequestContext> from( static Future<HttpRequestContext> from(
HttpRequest request, Angel app, String path) { HttpRequest request, Protevus app, String path) {
var ctx = HttpRequestContext().._container = app.container.createChild(); var ctx = HttpRequestContext().._container = app.container.createChild();
var override = request.method; var override = request.method;

View file

@ -18,7 +18,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
final HttpRequestContext? _correspondingRequest; final HttpRequestContext? _correspondingRequest;
bool _isDetached = false, _isClosed = false, _streamInitialized = false; bool _isDetached = false, _isClosed = false, _streamInitialized = false;
HttpResponseContext(this.rawResponse, Angel? app, HttpResponseContext(this.rawResponse, Protevus? app,
[this._correspondingRequest]) { [this._correspondingRequest]) {
this.app = app; this.app = app;
} }

View file

@ -15,20 +15,20 @@ Future<SecureServerSocket> startSharedHttp2(
return SecureServerSocket.bind(address, port, ctx, shared: true); return SecureServerSocket.bind(address, port, ctx, shared: true);
} }
/// Adapts `package:http2`'s [ServerTransportConnection] to serve Angel. /// Adapts `package:http2`'s [ServerTransportConnection] to serve Protevus.
class AngelHttp2 extends Driver<Socket, ServerTransportStream, class ProtevusHttp2 extends Driver<Socket, ServerTransportStream,
SecureServerSocket, Http2RequestContext, Http2ResponseContext> { SecureServerSocket, Http2RequestContext, Http2ResponseContext> {
final ServerSettings? settings; final ServerSettings? settings;
late AngelHttp _http; late ProtevusHttp _http;
final StreamController<HttpRequest> _onHttp1 = StreamController(); final StreamController<HttpRequest> _onHttp1 = StreamController();
final Map<String, MockHttpSession> _sessions = {}; final Map<String, MockHttpSession> _sessions = {};
final Uuid _uuid = Uuid(); final Uuid _uuid = Uuid();
_AngelHttp2ServerSocket? _artificial; _ProtevusHttp2ServerSocket? _artificial;
SecureServerSocket? get socket => _artificial; SecureServerSocket? get socket => _artificial;
AngelHttp2._( ProtevusHttp2._(
Angel app, Protevus app,
Future<SecureServerSocket> Function(dynamic, int) serverGenerator, Future<SecureServerSocket> Function(dynamic, int) serverGenerator,
bool useZone, bool useZone,
bool allowHttp1, bool allowHttp1,
@ -39,21 +39,21 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
useZone: useZone, useZone: useZone,
) { ) {
if (allowHttp1) { if (allowHttp1) {
_http = AngelHttp(app, useZone: useZone); _http = ProtevusHttp(app, useZone: useZone);
onHttp1.listen(_http.handleRequest); onHttp1.listen(_http.handleRequest);
} }
} }
factory AngelHttp2(Angel app, SecurityContext securityContext, factory ProtevusHttp2(Protevus app, SecurityContext securityContext,
{bool useZone = true, {bool useZone = true,
bool allowHttp1 = false, bool allowHttp1 = false,
ServerSettings? settings}) { ServerSettings? settings}) {
return AngelHttp2.custom(app, securityContext, SecureServerSocket.bind, return ProtevusHttp2.custom(app, securityContext, SecureServerSocket.bind,
allowHttp1: allowHttp1, settings: settings); allowHttp1: allowHttp1, settings: settings);
} }
factory AngelHttp2.custom( factory ProtevusHttp2.custom(
Angel app, Protevus app,
SecurityContext ctx, SecurityContext ctx,
Future<SecureServerSocket> Function( Future<SecureServerSocket> Function(
InternetAddress? address, int port, SecurityContext ctx) InternetAddress? address, int port, SecurityContext ctx)
@ -61,7 +61,7 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
{bool useZone = true, {bool useZone = true,
bool allowHttp1 = false, bool allowHttp1 = false,
ServerSettings? settings}) { ServerSettings? settings}) {
return AngelHttp2._(app, (address, port) { return ProtevusHttp2._(app, (address, port) {
var addr = address is InternetAddress var addr = address is InternetAddress
? address ? address
: InternetAddress(address.toString()); : InternetAddress(address.toString());
@ -75,7 +75,7 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
@override @override
Future<SecureServerSocket> generateServer([address, int? port]) async { Future<SecureServerSocket> generateServer([address, int? port]) async {
var s = await serverGenerator(address ?? '127.0.0.1', port ?? 0); var s = await serverGenerator(address ?? '127.0.0.1', port ?? 0);
return _artificial = _AngelHttp2ServerSocket(s, this); return _artificial = _ProtevusHttp2ServerSocket(s, this);
} }
@override @override
@ -158,7 +158,7 @@ class AngelHttp2 extends Driver<Socket, ServerTransportStream,
} }
class _FakeServerSocket extends Stream<Socket> implements ServerSocket { class _FakeServerSocket extends Stream<Socket> implements ServerSocket {
final _AngelHttp2ServerSocket angel; final _ProtevusHttp2ServerSocket angel;
final _ctrl = StreamController<Socket>(); final _ctrl = StreamController<Socket>();
_FakeServerSocket(this.angel); _FakeServerSocket(this.angel);
@ -183,15 +183,15 @@ class _FakeServerSocket extends Stream<Socket> implements ServerSocket {
} }
} }
class _AngelHttp2ServerSocket extends Stream<SecureSocket> class _ProtevusHttp2ServerSocket extends Stream<SecureSocket>
implements SecureServerSocket { implements SecureServerSocket {
final SecureServerSocket socket; final SecureServerSocket socket;
final AngelHttp2 driver; final ProtevusHttp2 driver;
final _ctrl = StreamController<SecureSocket>(); final _ctrl = StreamController<SecureSocket>();
late _FakeServerSocket _fake; late _FakeServerSocket _fake;
StreamSubscription? _sub; StreamSubscription? _sub;
_AngelHttp2ServerSocket(this.socket, this.driver) { _ProtevusHttp2ServerSocket(this.socket, this.driver) {
_fake = _FakeServerSocket(this); _fake = _FakeServerSocket(this);
HttpServer.listenOn(_fake).pipe(driver._onHttp1); HttpServer.listenOn(_fake).pipe(driver._onHttp1);
_sub = socket.listen( _sub = socket.listen(
@ -206,7 +206,7 @@ class _AngelHttp2ServerSocket extends Stream<SecureSocket>
} else { } else {
socket.destroy(); socket.destroy();
throw Exception( throw Exception(
'AngelHttp2 does not support ${socket.selectedProtocol} as an ALPN protocol.'); 'ProtevusHttp2 does not support ${socket.selectedProtocol} as an ALPN protocol.');
} }
}, },
onDone: _ctrl.close, onDone: _ctrl.close,

View file

@ -31,7 +31,7 @@ class Http2RequestContext extends RequestContext<ServerTransportStream?> {
static Future<Http2RequestContext> from( static Future<Http2RequestContext> from(
ServerTransportStream stream, ServerTransportStream stream,
Socket socket, Socket socket,
Angel app, Protevus app,
Map<String, MockHttpSession> sessions, Map<String, MockHttpSession> sessions,
Uuid uuid) { Uuid uuid) {
var c = Completer<Http2RequestContext>(); var c = Completer<Http2RequestContext>();

View file

@ -23,7 +23,7 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
Uri? _targetUri; Uri? _targetUri;
Http2ResponseContext(Angel? app, this.stream, this._req) { Http2ResponseContext(Protevus? app, this.stream, this._req) {
this.app = app; this.app = app;
_targetUri = _req?.uri; _targetUri = _req?.uri;
} }

View file

@ -5,8 +5,8 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:platform_framework/http.dart'; import 'package:platform_framework/http.dart';
void main() async { void main() async {
var app = Angel(); var app = Protevus();
var http = AngelHttp.custom(app, startShared, useZone: false); var http = ProtevusHttp.custom(app, startShared, useZone: false);
app.get('/', (req, res) => res.write('Hello, world!')); app.get('/', (req, res) => res.write('Hello, world!'));
app.optimizeForProduction(force: true); app.optimizeForProduction(force: true);

View file

@ -64,7 +64,7 @@ Future<RequestContext> acceptContentTypes(
var rq = MockHttpRequest('GET', endpoint, persistentConnection: false); var rq = MockHttpRequest('GET', endpoint, persistentConnection: false);
rq.headers.set('accept', headerString); rq.headers.set('accept', headerString);
rq.close(); rq.close();
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var http = AngelHttp(app); var http = ProtevusHttp(app);
return http.createRequestContext(rq, rq.response); return http.createRequestContext(rq, rq.response);
} }

View file

@ -7,8 +7,8 @@ import 'package:platform_mock_request/platform_mock_request.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
var app = Angel(); var app = Protevus();
var http = AngelHttp(app); var http = ProtevusHttp(app);
Future<RequestContext> request( Future<RequestContext> request(
{bool asJson = true, {bool asJson = true,

View file

@ -70,7 +70,7 @@ bool bar(RequestContext req, ResponseContext res) {
} }
void main() { void main() {
late Angel app; late Protevus app;
late TodoController todoController; late TodoController todoController;
late NoExposeController noExposeCtrl; late NoExposeController noExposeCtrl;
late HttpServer server; late HttpServer server;
@ -78,7 +78,7 @@ void main() {
String? url; String? url;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
app.get( app.get(
'/redirect', '/redirect',
(req, res) async => (req, res) async =>
@ -104,7 +104,7 @@ void main() {
print(app.controllers); print(app.controllers);
app.dumpTree(); app.dumpTree();
server = await AngelHttp(app).startServer(); server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.address}:${server.port}'; url = 'http://${server.address.address}:${server.port}';
}); });
@ -118,20 +118,20 @@ void main() {
}); });
test('create dynamic handler', () async { test('create dynamic handler', () async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
app.get( app.get(
'/foo', '/foo',
ioc(({String? bar}) { ioc(({String? bar}) {
return 2; return 2;
}, optional: ['bar'])); }, optional: ['bar']));
var rq = MockHttpRequest('GET', Uri(path: 'foo')); var rq = MockHttpRequest('GET', Uri(path: 'foo'));
await AngelHttp(app).handleRequest(rq); await ProtevusHttp(app).handleRequest(rq);
var body = await utf8.decoder.bind(rq.response).join(); var body = await utf8.decoder.bind(rq.response).join();
expect(json.decode(body), 2); expect(json.decode(body), 2);
}); });
test('optional name', () async { test('optional name', () async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
await app.configure(NamedController().configureServer); await app.configure(NamedController().configureServer);
expect(app.controllers['foo'], const IsInstanceOf<NamedController>()); expect(app.controllers['foo'], const IsInstanceOf<NamedController>());
}); });

View file

@ -5,11 +5,11 @@ import 'package:platform_mock_request/platform_mock_request.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
late AngelHttp http; late ProtevusHttp http;
setUp(() async { setUp(() async {
var app = Angel(); var app = Protevus();
http = AngelHttp(app); http = ProtevusHttp(app);
app.get('/detach', (req, res) async { app.get('/detach', (req, res) async {
if (res is HttpResponseContext) { if (res is HttpResponseContext) {

View file

@ -15,13 +15,13 @@ final String sampleText = 'make your bed';
final String sampleOver = 'never'; final String sampleOver = 'never';
void main() { void main() {
late Angel app; late Protevus app;
late http.Client client; late http.Client client;
late HttpServer server; late HttpServer server;
String? url; String? url;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
client = http.Client(); client = http.Client();
// Inject some todos // Inject some todos
@ -41,7 +41,7 @@ void main() {
await app.configure(SingletonController().configureServer); await app.configure(SingletonController().configureServer);
await app.configure(ErrandController().configureServer); await app.configure(ErrandController().configureServer);
server = await AngelHttp(app).startServer(); server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });
@ -52,7 +52,7 @@ void main() {
}); });
test('runContained with custom container', () async { test('runContained with custom container', () async {
var app = Angel(); var app = Protevus();
var c = Container(const MirrorsReflector()); var c = Container(const MirrorsReflector());
c.registerSingleton(Todo(text: 'Hey!')); c.registerSingleton(Todo(text: 'Hey!'));
@ -63,7 +63,7 @@ void main() {
var rq = MockHttpRequest('GET', Uri(path: '/')); var rq = MockHttpRequest('GET', Uri(path: '/'));
await rq.close(); await rq.close();
var rs = rq.response; var rs = rq.response;
await AngelHttp(app).handleRequest(rq); await ProtevusHttp(app).handleRequest(rq);
var text = await rs.transform(utf8.decoder).join(); var text = await rs.transform(utf8.decoder).join();
expect(text, json.encode('Hey!')); expect(text, json.encode('Hey!'));
}); });

View file

@ -17,10 +17,10 @@ Future<List<int>> getBody(MockHttpResponse rs) async {
} }
void main() { void main() {
late Angel app; late Protevus app;
setUp(() { setUp(() {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
app.encoders.addAll( app.encoders.addAll(
{ {
'deflate': zlib.encoder, 'deflate': zlib.encoder,
@ -40,14 +40,14 @@ void main() {
encodingTests(() => app); encodingTests(() => app);
} }
void encodingTests(Angel Function() getApp) { void encodingTests(Protevus Function() getApp) {
group('encoding', () { group('encoding', () {
Angel app; Protevus app;
late AngelHttp http; late ProtevusHttp http;
setUp(() { setUp(() {
app = getApp(); app = getApp();
http = AngelHttp(app); http = ProtevusHttp(app);
}); });
test('sends plaintext if no accept-encoding', () async { test('sends plaintext if no accept-encoding', () async {

View file

@ -3,16 +3,17 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
test('custom value', () => expect(AngelEnvironment('hey').value, 'hey')); test('custom value', () => expect(ProtevusEnvironment('hey').value, 'hey'));
test('lowercases', () => expect(AngelEnvironment('HeY').value, 'hey')); test('lowercases', () => expect(ProtevusEnvironment('HeY').value, 'hey'));
test( test(
'default to env or development', 'default to env or development',
() => expect(AngelEnvironment().value, () => expect(ProtevusEnvironment().value,
(Platform.environment['ANGEL_ENV'] ?? 'development').toLowerCase())); (Platform.environment['ANGEL_ENV'] ?? 'development').toLowerCase()));
test('isDevelopment', test('isDevelopment',
() => expect(AngelEnvironment('development').isDevelopment, true)); () => expect(ProtevusEnvironment('development').isDevelopment, true));
test('isStaging', () => expect(AngelEnvironment('staging').isStaging, true)); test('isStaging',
() => expect(ProtevusEnvironment('staging').isStaging, true));
test('isDevelopment', test('isDevelopment',
() => expect(AngelEnvironment('production').isProduction, true)); () => expect(ProtevusEnvironment('production').isProduction, true));
} }

View file

@ -26,7 +26,7 @@ void main() {
Future<RequestContext> makeRequest(String path) { Future<RequestContext> makeRequest(String path) {
var rq = MockHttpRequest('GET', endpoint.replace(path: path))..close(); var rq = MockHttpRequest('GET', endpoint.replace(path: path))..close();
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var http = AngelHttp(app); var http = ProtevusHttp(app);
return http.createRequestContext(rq, rq.response); return http.createRequestContext(rq, rq.response);
} }

View file

@ -3,18 +3,18 @@ import 'package:test/test.dart';
import 'common.dart'; import 'common.dart';
void main() { void main() {
var throwsAnAngelHttpException = throwsA(const IsInstanceOf<HttpException>()); var throwsAnHttpException = throwsA(const IsInstanceOf<HttpException>());
/* /*
test('throw 404 on null', () { test('throw 404 on null', () {
var service = AnonymousService(index: ([p]) => null); var service = AnonymousService(index: ([p]) => null);
expect(() => service.findOne(), throwsAnAngelHttpException); expect(() => service.findOne(), throwsAnHttpException);
}); });
*/ */
test('throw 404 on empty iterable', () { test('throw 404 on empty iterable', () {
var service = AnonymousService(index: ([p]) => []); var service = AnonymousService(index: ([p]) => []);
expect(() => service.findOne(), throwsAnAngelHttpException); expect(() => service.findOne(), throwsAnHttpException);
}); });
test('return first element of iterable', () async { test('return first element of iterable', () async {

View file

@ -7,18 +7,18 @@ import 'package:http/http.dart' as http;
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
late Angel app; late Protevus app;
late http.Client client; late http.Client client;
late HttpServer server; late HttpServer server;
late String url; late String url;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()) app = Protevus(reflector: MirrorsReflector())
..post('/foo', (req, res) => res.serialize({'hello': 'world'})) ..post('/foo', (req, res) => res.serialize({'hello': 'world'}))
..all('*', (req, res) => throw HttpException.notFound()); ..all('*', (req, res) => throw HttpException.notFound());
client = http.Client(); client = http.Client();
server = await AngelHttp(app).startServer(); server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });

View file

@ -13,14 +13,14 @@ void main() {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}; };
late Angel app; late Protevus app;
late HttpServer server; late HttpServer server;
late String url; late String url;
late http.Client client; late http.Client client;
late HookedService todoService; late HookedService todoService;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
client = http.Client(); client = http.Client();
app.use('/todos', MapService()); app.use('/todos', MapService());
app.use('/books', BookService()); app.use('/books', BookService());
@ -36,7 +36,7 @@ void main() {
throw e.error as Object; throw e.error as Object;
}; };
server = await AngelHttp(app).startServer(); server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });

View file

@ -25,12 +25,13 @@ Stream<List<int>> jfkStream() {
void main() { void main() {
var client = Http2Client(); var client = Http2Client();
late IOClient h1c; late IOClient h1c;
Angel app; Protevus app;
late AngelHttp2 http2; late ProtevusHttp2 http2;
late Uri serverRoot; late Uri serverRoot;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector())..encoders['gzip'] = gzip.encoder; app = Protevus(reflector: MirrorsReflector())
..encoders['gzip'] = gzip.encoder;
hierarchicalLoggingEnabled = true; hierarchicalLoggingEnabled = true;
app.logger = Logger.detached('angel.http2') app.logger = Logger.detached('angel.http2')
..onRecord.listen((rec) { ..onRecord.listen((rec) {
@ -105,7 +106,7 @@ void main() {
// Create an HTTP client that trusts our server. // Create an HTTP client that trusts our server.
h1c = IOClient(HttpClient()..badCertificateCallback = (_, __, ___) => true); h1c = IOClient(HttpClient()..badCertificateCallback = (_, __, ___) => true);
http2 = AngelHttp2(app, ctx, allowHttp1: true); http2 = ProtevusHttp2(app, ctx, allowHttp1: true);
var server = await http2.startServer(); var server = await http2.startServer();
serverRoot = Uri.parse('https://127.0.0.1:${server.port}'); serverRoot = Uri.parse('https://127.0.0.1:${server.port}');

View file

@ -9,7 +9,7 @@ import 'pretty_log.dart';
void main() { void main() {
late http.IOClient client; late http.IOClient client;
late AngelHttp driver; late ProtevusHttp driver;
late Logger logger; late Logger logger;
setUp(() async { setUp(() async {
@ -20,7 +20,7 @@ void main() {
..level = Level.ALL ..level = Level.ALL
..onRecord.listen(prettyLog); ..onRecord.listen(prettyLog);
var app = Angel(logger: logger); var app = Protevus(logger: logger);
app.fallback(hello); app.fallback(hello);
app.fallback(throw404); app.fallback(throw404);
@ -40,7 +40,7 @@ void main() {
} }
}; };
driver = AngelHttp(app); driver = ProtevusHttp(app);
await driver.startServer(); await driver.startServer();
}); });

View file

@ -7,8 +7,8 @@ import 'package:platform_mock_request/platform_mock_request.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
var app = Angel(); var app = Protevus();
var http = AngelHttp(app); var http = ProtevusHttp(app);
app.get('/default', (req, res) => res.jsonp({'foo': 'bar'})); app.get('/default', (req, res) => res.jsonp({'foo': 'bar'}));

View file

@ -24,12 +24,12 @@ void main() {
} }
void parameterMetaTests() { void parameterMetaTests() {
Angel app; Protevus app;
late AngelHttp http; late ProtevusHttp http;
setUp(() { setUp(() {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
http = AngelHttp(app); http = ProtevusHttp(app);
app.get('/cookie', ioc((@CookieValue('token') String jwt) { app.get('/cookie', ioc((@CookieValue('token') String jwt) {
return jwt; return jwt;

View file

@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() { void main() {
test('preinjects functions', () async { test('preinjects functions', () async {
var app = Angel(reflector: MirrorsReflector()) var app = Protevus(reflector: MirrorsReflector())
..configuration['foo'] = 'bar' ..configuration['foo'] = 'bar'
..get('/foo', ioc(echoAppFoo)); ..get('/foo', ioc(echoAppFoo));
app.optimizeForProduction(force: true); app.optimizeForProduction(force: true);
@ -18,11 +18,11 @@ void main() {
var rq = MockHttpRequest('GET', Uri(path: '/foo')); var rq = MockHttpRequest('GET', Uri(path: '/foo'));
await rq.close(); await rq.close();
await AngelHttp(app).handleRequest(rq); await ProtevusHttp(app).handleRequest(rq);
var rs = rq.response; var rs = rq.response;
var body = await rs.transform(utf8.decoder).join(); var body = await rs.transform(utf8.decoder).join();
expect(body, json.encode('bar')); expect(body, json.encode('bar'));
}, skip: 'Angel no longer has to preinject functions'); }, skip: 'Protevus no longer has to preinject functions');
} }
String echoAppFoo(String foo) => foo; String echoAppFoo(String foo) => foo;

View file

@ -9,13 +9,13 @@ import 'package:platform_mock_request/platform_mock_request.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
late Angel app; late Protevus app;
late AngelHttp http; late ProtevusHttp http;
setUp(() { setUp(() {
app = Angel(reflector: MirrorsReflector()) app = Protevus(reflector: MirrorsReflector())
..configuration['global'] = 305; // Pitbull! ..configuration['global'] = 305; // Pitbull!
http = AngelHttp(app); http = ProtevusHttp(app);
app.get('/string/:string', ioc((String string) => string)); app.get('/string/:string', ioc((String string) => string));

View file

@ -13,10 +13,10 @@ void main() {
} }
test('can request the same url twice', () async { test('can request the same url twice', () async {
var app = Angel(reflector: MirrorsReflector()) var app = Protevus(reflector: MirrorsReflector())
..get('/test/:id', ioc((id) => 'Hello $id')); ..get('/test/:id', ioc((id) => 'Hello $id'));
var rq1 = mk(1), rq2 = mk(2), rq3 = mk(1); var rq1 = mk(1), rq2 = mk(2), rq3 = mk(1);
await Future.wait([rq1, rq2, rq3].map(AngelHttp(app).handleRequest)); await Future.wait([rq1, rq2, rq3].map(ProtevusHttp(app).handleRequest));
var body1 = await rq1.response.transform(utf8.decoder).join(), var body1 = await rq1.response.transform(utf8.decoder).join(),
body2 = await rq2.response.transform(utf8.decoder).join(), body2 = await rq2.response.transform(utf8.decoder).join(),
body3 = await rq3.response.transform(utf8.decoder).join(); body3 = await rq3.response.transform(utf8.decoder).join();

View file

@ -8,7 +8,7 @@ import 'pretty_log.dart';
void main() { void main() {
late http.IOClient client; late http.IOClient client;
late AngelHttp driver; late ProtevusHttp driver;
late Logger logger; late Logger logger;
late StringBuffer buf; late StringBuffer buf;
@ -21,14 +21,14 @@ void main() {
..level = Level.ALL ..level = Level.ALL
..onRecord.listen(prettyLog); ..onRecord.listen(prettyLog);
var app = Angel(logger: logger); var app = Protevus(logger: logger);
app.fallback((req, res) { app.fallback((req, res) {
req.shutdownHooks.add(() => buf.write('Hello, ')); req.shutdownHooks.add(() => buf.write('Hello, '));
req.shutdownHooks.add(() => buf.write('world!')); req.shutdownHooks.add(() => buf.write('world!'));
}); });
driver = AngelHttp(app); driver = ProtevusHttp(app);
await driver.startServer(); await driver.startServer();
}); });

View file

@ -6,13 +6,13 @@ import 'package:platform_framework/src/http/angel_http.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
late Angel app; late Protevus app;
late AngelHttp http; late ProtevusHttp http;
late HttpClient client; late HttpClient client;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
http = AngelHttp(app); http = ProtevusHttp(app);
await http.startServer(); await http.startServer();

View file

@ -36,16 +36,16 @@ bool interceptService(RequestContext req, ResponseContext res) {
} }
void main() { void main() {
late Angel app; late Protevus app;
late Angel nested; late Protevus nested;
late Angel todos; late Protevus todos;
late String url; late String url;
late http.Client client; late http.Client client;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
nested = Angel(reflector: MirrorsReflector()); nested = Protevus(reflector: MirrorsReflector());
todos = Angel(reflector: MirrorsReflector()); todos = Protevus(reflector: MirrorsReflector());
for (var app in [app, nested, todos]) { for (var app in [app, nested, todos]) {
app.logger = Logger('routing_test') app.logger = Logger('routing_test')
@ -113,7 +113,7 @@ void main() {
//app.dumpTree(header: "DUMPING ROUTES:", showMatchers: true); //app.dumpTree(header: "DUMPING ROUTES:", showMatchers: true);
client = http.Client(); client = http.Client();
var server = await AngelHttp(app).startServer('127.0.0.1', 0); var server = await ProtevusHttp(app).startServer('127.0.0.1', 0);
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });
@ -141,13 +141,13 @@ void main() {
expect(response.body, equals('abc')); expect(response.body, equals('abc'));
}); });
test('Can nest another Angel instance', () async { test('Can nest another Protevus instance', () async {
var response = await client.post(Uri.parse('$url/nes/ted/foo')); var response = await client.post(Uri.parse('$url/nes/ted/foo'));
var json_ = json.decode(response.body); var json_ = json.decode(response.body);
expect(json_['route'], equals('foo')); expect(json_['route'], equals('foo'));
}); });
test('Can parse parameters from a nested Angel instance', () async { test('Can parse parameters from a nested Protevus instance', () async {
var response = await client.get(Uri.parse('$url/todos/1337/action/test')); var response = await client.get(Uri.parse('$url/todos/1337/action/test'));
var json_ = json.decode(response.body); var json_ = json.decode(response.body);
print('JSON: $json_'); print('JSON: $json_');
@ -184,9 +184,9 @@ void main() {
test('Can name routes', () { test('Can name routes', () {
Route foo = app.get('/framework/:id', null)..name = 'frm'; Route foo = app.get('/framework/:id', null)..name = 'frm';
print('Foo: $foo'); print('Foo: $foo');
String uri = foo.makeUri({'id': 'angel'}); String uri = foo.makeUri({'id': 'Protevus'});
print(uri); print(uri);
expect(uri, equals('framework/angel')); expect(uri, equals('framework/Protevus'));
}); });
*/ */

View file

@ -8,13 +8,13 @@ import 'package:http_parser/http_parser.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
late Angel app; late Protevus app;
late http.Client client; late http.Client client;
late HttpServer server; late HttpServer server;
late String url; late String url;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()) app = Protevus(reflector: MirrorsReflector())
..get('/foo', ioc(() => {'hello': 'world'})) ..get('/foo', ioc(() => {'hello': 'world'}))
..get('/bar', (req, res) async { ..get('/bar', (req, res) async {
await res.serialize({'hello': 'world'}, await res.serialize({'hello': 'world'},
@ -22,7 +22,7 @@ void main() {
}); });
client = http.Client(); client = http.Client();
server = await AngelHttp(app).startServer(); server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });

View file

@ -14,8 +14,9 @@ final Uri $foo = Uri.parse('http://localhost:3000/foo');
/// Additional tests to improve coverage of server.dart /// Additional tests to improve coverage of server.dart
void main() { void main() {
group('scoping', () { group('scoping', () {
var parent = Angel(reflector: MirrorsReflector())..configuration['two'] = 2; var parent = Protevus(reflector: MirrorsReflector())
var child = Angel(reflector: MirrorsReflector()); ..configuration['two'] = 2;
var child = Protevus(reflector: MirrorsReflector());
parent.mount('/child', child); parent.mount('/child', child);
test('sets children', () { test('sets children', () {
@ -32,14 +33,14 @@ void main() {
}); });
test('custom server generator', () { test('custom server generator', () {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var http = AngelHttp.custom(app, HttpServer.bind); var http = ProtevusHttp.custom(app, HttpServer.bind);
expect(http.serverGenerator, HttpServer.bind); expect(http.serverGenerator, HttpServer.bind);
}); });
test('default error handler', () async { test('default error handler', () async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var http = AngelHttp(app); var http = ProtevusHttp(app);
var rq = MockHttpRequest('GET', $foo); var rq = MockHttpRequest('GET', $foo);
await (rq.close()); await (rq.close());
var rs = rq.response; var rs = rq.response;
@ -61,10 +62,10 @@ void main() {
}); });
test('plug-ins run on startup', () async { test('plug-ins run on startup', () async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
app.startupHooks.add((app) => app.configuration['two'] = 2); app.startupHooks.add((app) => app.configuration['two'] = 2);
var http = AngelHttp(app); var http = ProtevusHttp(app);
await http.startServer(); await http.startServer();
expect(app.configuration['two'], 2); expect(app.configuration['two'], 2);
await app.close(); await app.close();
@ -72,7 +73,7 @@ void main() {
}); });
test('warning when adding routes to flattened router', () { test('warning when adding routes to flattened router', () {
var app = Angel(reflector: MirrorsReflector()) var app = Protevus(reflector: MirrorsReflector())
..optimizeForProduction(force: true); ..optimizeForProduction(force: true);
app.dumpTree(); app.dumpTree();
app.get('/', (req, res) => 2); app.get('/', (req, res) => 2);
@ -80,7 +81,7 @@ void main() {
}); });
test('services close on close call', () async { test('services close on close call', () async {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var svc = CustomCloseService(); var svc = CustomCloseService();
expect(svc.value, 2); expect(svc.value, 2);
app.use('/', svc); app.use('/', svc);
@ -89,8 +90,8 @@ void main() {
}); });
test('global injection added to injection map', () async { test('global injection added to injection map', () async {
var app = Angel(reflector: MirrorsReflector())..configuration['a'] = 'b'; var app = Protevus(reflector: MirrorsReflector())..configuration['a'] = 'b';
var http = AngelHttp(app); var http = ProtevusHttp(app);
app.get('/', ioc((String a) => a)); app.get('/', ioc((String a) => a));
var rq = MockHttpRequest('GET', Uri.parse('/')); var rq = MockHttpRequest('GET', Uri.parse('/'));
await (rq.close()); await (rq.close());
@ -100,8 +101,8 @@ void main() {
}); });
test('global injected serializer', () async { test('global injected serializer', () async {
var app = Angel(reflector: MirrorsReflector())..serializer = (_) => 'x'; var app = Protevus(reflector: MirrorsReflector())..serializer = (_) => 'x';
var http = AngelHttp(app); var http = ProtevusHttp(app);
app.get($foo.path, (req, ResponseContext res) => res.serialize(null)); app.get($foo.path, (req, ResponseContext res) => res.serialize(null));
var rq = MockHttpRequest('GET', $foo); var rq = MockHttpRequest('GET', $foo);
await (rq.close()); await (rq.close());
@ -111,8 +112,8 @@ void main() {
}); });
group('handler results', () { group('handler results', () {
var app = Angel(reflector: MirrorsReflector()); var app = Protevus(reflector: MirrorsReflector());
var http = AngelHttp(app); var http = ProtevusHttp(app);
app.responseFinalizers.add((req, res) => throw HttpException.forbidden()); app.responseFinalizers.add((req, res) => throw HttpException.forbidden());
late RequestContext req; late RequestContext req;
late ResponseContext res; late ResponseContext res;
@ -153,14 +154,14 @@ void main() {
}); });
group('handleHttpException', () { group('handleHttpException', () {
late Angel app; late Protevus app;
late AngelHttp http; late ProtevusHttp http;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
app.get('/wtf', (req, res) => throw HttpException.forbidden()); app.get('/wtf', (req, res) => throw HttpException.forbidden());
app.get('/wtf2', (req, res) => throw HttpException.forbidden()); app.get('/wtf2', (req, res) => throw HttpException.forbidden());
http = AngelHttp(app); http = ProtevusHttp(app);
await http.startServer('127.0.0.1', 0); await http.startServer('127.0.0.1', 0);
var oldHandler = app.errorHandler; var oldHandler = app.errorHandler;

View file

@ -16,20 +16,20 @@ void main() {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}; };
late Angel app; late Protevus app;
late MapService service; late MapService service;
late String url; late String url;
late http.Client client; late http.Client client;
setUp(() async { setUp(() async {
app = Angel(reflector: MirrorsReflector()) app = Protevus(reflector: MirrorsReflector())
..use('/todos', service = MapService()) ..use('/todos', service = MapService())
..errorHandler = (e, req, res) { ..errorHandler = (e, req, res) {
if (e.error != null) print('Whoops: ${e.error}'); if (e.error != null) print('Whoops: ${e.error}');
if (e.stackTrace != null) print(Chain.forTrace(e.stackTrace!).terse); if (e.stackTrace != null) print(Chain.forTrace(e.stackTrace!).terse);
}; };
var server = await AngelHttp(app).startServer(); var server = await ProtevusHttp(app).startServer();
client = http.Client(); client = http.Client();
url = 'http://${server.address.host}:${server.port}'; url = 'http://${server.address.host}:${server.port}';
}); });

View file

@ -13,12 +13,12 @@ import 'package:test/test.dart';
import 'encoders_buffer_test.dart' show encodingTests; import 'encoders_buffer_test.dart' show encodingTests;
void main() { void main() {
late Angel app; late Protevus app;
late AngelHttp http; late ProtevusHttp http;
setUp(() { setUp(() {
app = Angel(reflector: MirrorsReflector()); app = Protevus(reflector: MirrorsReflector());
http = AngelHttp(app, useZone: true); http = ProtevusHttp(app, useZone: true);
app.logger = Logger('streaming_test') app.logger = Logger('streaming_test')
..onRecord.listen((rec) { ..onRecord.listen((rec) {

View file

@ -3,7 +3,7 @@ import 'package:test/test.dart';
void main() { void main() {
test('default view generator', () async { test('default view generator', () async {
var app = Angel(); var app = Protevus();
var view = await app.viewGenerator!('foo', {'bar': 'baz'}); var view = await app.viewGenerator!('foo', {'bar': 'baz'});
expect(view, contains('No view engine')); expect(view, contains('No view engine'));
}); });

View file

@ -9,7 +9,7 @@ void main() {
//var uri = Uri.parse('http://localhost:3000'); //var uri = Uri.parse('http://localhost:3000');
/* /*
var app = Angel() var app = Protevus()
..get('/foo', (req, res) => 'Hello, world!') ..get('/foo', (req, res) => 'Hello, world!')
..post('/body', ..post('/body',
(req, res) => req.parseBody().then((_) => req.bodyAsMap.length)) (req, res) => req.parseBody().then((_) => req.bodyAsMap.length))
@ -20,7 +20,7 @@ void main() {
return res.serialize(req.ip == InternetAddress.loopbackIPv4.address); return res.serialize(req.ip == InternetAddress.loopbackIPv4.address);
}); });
var http = AngelHttp(app); var http = ProtevusHttp(app);
test('receive a response', () async { test('receive a response', () async {
var rq = MockHttpRequest('GET', uri.resolve('/foo')); var rq = MockHttpRequest('GET', uri.resolve('/foo'));

View file

@ -1,6 +1,6 @@
name: protevus_platform name: protevus_platform
description: The Protevus Platform description: The Protevus Platform
version: 0.0.1 version: 9.0.0
homepage: https://protevus.com homepage: https://protevus.com
documentation: https://docs.protevus.com documentation: https://docs.protevus.com
repository: https://github.com/protevus/platform repository: https://github.com/protevus/platform