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/empty/empty.dart';

View file

@ -2,7 +2,7 @@ import '../reflector.dart';
/// 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 {
final Map<Symbol, String> names;
final Map<Type, ReflectedType> types;

View file

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

View file

@ -6,7 +6,7 @@ import 'package:platform_framework/http.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel(reflector: MirrorsReflector())
var app = Protevus(reflector: MirrorsReflector())
..logger = (Logger('angel')
..onRecord.listen((rec) {
print(rec);
@ -18,7 +18,7 @@ void main() async {
app.fallback(
(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);
var url = 'http://${server.address.address}:${server.port}';
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:logging/logging.dart';
Future<void> apiConfigurer(Angel app) async {
Future<void> apiConfigurer(Protevus app) async {
app.get('/', (req, res) => 'Hello, API!');
app.fallback((req, res) {
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.)');
}
@ -19,8 +19,8 @@ void main() async {
hierarchicalLoggingEnabled = true;
//Logger.root.onRecord.listen(prettyLog);
var app = Angel(logger: Logger('angel'));
var http = AngelHttp(app);
var app = Protevus(logger: Logger('angel'));
var http = ProtevusHttp(app);
var multiHost = HostnameRouter.configure({
'api.localhost:3000': apiConfigurer,
'localhost:3000': frontendConfigurer,

View file

@ -6,7 +6,7 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel();
var app = Protevus();
app.logger = Logger('angel')
..onRecord.listen((rec) {
print(rec);
@ -35,10 +35,10 @@ void main() async {
st);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
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);
var server = await http2.startServer('127.0.0.1', 3000);

View file

@ -6,7 +6,7 @@ import 'package:logging/logging.dart';
import 'common.dart';
void main() async {
var app = Angel()
var app = Protevus()
..encoders.addAll({
'gzip': gzip.encoder,
'deflate': zlib.encoder,
@ -32,10 +32,10 @@ void main() async {
);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
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);
await http2.startServer('127.0.0.1', 3000);

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart';
void main() async {
var app = Angel();
var app = Protevus();
app.logger = Logger('angel')
..onRecord.listen((rec) {
print(rec);
@ -51,10 +51,10 @@ void main() async {
st);
}
var http1 = AngelHttp(app);
var http2 = AngelHttp2(app, ctx);
var http1 = ProtevusHttp(app);
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);
var server = await http2.startServer('127.0.0.1', 3000);

View file

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

View file

@ -8,13 +8,13 @@ void main() async {
//Logger.root.onRecord.listen(prettyLog);
// Create our server.
var app = Angel(
var app = Protevus(
logger: Logger('angel'),
reflector: MirrorsReflector(),
);
// 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.
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 url = 'http://${server.address.address}:${server.port}';
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/?name=emoji');
print('* $url/greet/?name=jack');

View file

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

View file

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

View file

@ -3,7 +3,7 @@ import 'package:platform_framework/platform_framework.dart';
import 'package:platform_framework/http.dart';
void main() async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
app.viewGenerator = (name, [data]) async =>
'View generator invoked with name $name and data: $data';
@ -11,7 +11,7 @@ void main() async {
// Index route. Returns JSON.
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 url = 'http://${server.address.address}:${server.port}';
print('Listening at $url');

View file

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

View file

@ -8,16 +8,16 @@ import 'package:stack_trace/stack_trace.dart';
import 'package:tuple/tuple.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<
Request,
Response,
Server extends Stream<Request>,
RequestContextType extends RequestContext,
ResponseContextType extends ResponseContext> {
final Angel app;
final Protevus app;
final bool useZone;
bool _closed = false;
@ -383,7 +383,7 @@ abstract class Driver<
MiddlewarePipelineIterator<RequestHandler> it,
RequestContextType req,
ResponseContextType res,
Angel app) async {
Protevus app) async {
var broken = false;
while (it.moveNext()) {
var current = it.current.handlers.iterator;

View file

@ -1,19 +1,19 @@
import 'dart:io';
/// A constant instance of [AngelEnv].
const AngelEnvironment angelEnv = AngelEnvironment();
/// A constant instance of [ProtevusEnv].
const ProtevusEnvironment protevusEnv = ProtevusEnvironment();
/// Queries the environment's `ANGEL_ENV` value.
class AngelEnvironment {
class ProtevusEnvironment {
final String? _customValue;
/// You can optionally provide a custom value, in order to override the system's
/// value.
const AngelEnvironment([this._customValue]);
const ProtevusEnvironment([this._customValue]);
/// Returns the value of the `ANGEL_ENV` variable; defaults to `'development'`.
String get value =>
(_customValue ?? Platform.environment['ANGEL_ENV'] ?? 'development')
(_customValue ?? Platform.environment['PROTEVUS_ENV'] ?? 'development')
.toLowerCase();
/// 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.
void addHooks(Angel app) {
void addHooks(Protevus app) {
var hooks = getAnnotation<Hooks>(inner, app.container.reflector);
var before = <HookedServiceEventListener<Id, Data, T>>[];
var after = <HookedServiceEventListener<Id, Data, T>>[];

View file

@ -24,13 +24,13 @@ import 'server.dart';
/// * `example.*` -> `/example\./[^$]*`
/// * `example.+` -> `/example\./[^$]+`
class HostnameRouter {
final Map<Pattern, Angel> _apps = {};
final Map<Pattern, FutureOr<Angel> Function()> _creators = {};
final Map<Pattern, Protevus> _apps = {};
final Map<Pattern, FutureOr<Protevus> Function()> _creators = {};
final List<Pattern> _patterns = [];
HostnameRouter(
{Map<Pattern, Angel> apps = const {},
Map<Pattern, FutureOr<Angel> Function()> creators = const {}}) {
{Map<Pattern, Protevus> apps = const {},
Map<Pattern, FutureOr<Protevus> Function()> creators = const {}}) {
Map<Pattern, V> parseMap<V>(Map<Pattern, V> map) {
return map.map((p, c) {
Pattern pp;
@ -55,16 +55,16 @@ class HostnameRouter {
}
factory HostnameRouter.configure(
Map<Pattern, FutureOr<void> Function(Angel)> configurers,
Map<Pattern, FutureOr<void> Function(Protevus)> configurers,
{Reflector reflector = const EmptyReflector(),
AngelEnvironment environment = angelEnv,
ProtevusEnvironment environment = protevusEnv,
Logger? logger,
bool allowMethodOverrides = true,
FutureOr<String> Function(dynamic)? serializer,
ViewGenerator? viewGenerator}) {
var creators = configurers.map((p, c) {
return MapEntry(p, () async {
var app = Angel(
var app = Protevus(
reflector: reflector,
environment: environment,
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:convert';
@ -18,13 +18,13 @@ import 'package:logging/logging.dart';
import 'metadata.dart';
import 'response_context.dart';
import 'routable.dart';
import 'server.dart' show Angel;
import 'server.dart' show Protevus;
part 'injection.dart';
/// A convenience wrapper around an incoming [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.
final _log = Logger('RequestContext');
@ -46,8 +46,8 @@ abstract class RequestContext<RawRequest> {
/// Additional params to be passed to services.
final Map<String, dynamic> serviceParams = {};
/// The [Angel] instance that is responding to this request.
Angel? app;
/// The [Protevus] instance that is responding to this request.
Protevus? app;
/// Any cookies sent with this request.
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**.
///
/// 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;
/// 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**.
///
/// 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;
/// 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**.
///
/// 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) {
if (_bodyObject != null) {
throw StateError(

View file

@ -13,7 +13,7 @@ import 'package:mime/mime.dart';
import 'controller.dart';
import 'request_context.dart';
import 'server.dart' show Angel;
import 'server.dart' show Protevus;
final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
@ -22,15 +22,15 @@ abstract class ResponseContext<RawResponse>
implements StreamConsumer<List<int>>, StreamSink<List<int>>, StringSink {
final Map properties = {};
final CaseInsensitiveMap<String> _headers = CaseInsensitiveMap<String>.from(
{'content-type': 'text/plain', 'server': 'Angel3'});
{'content-type': 'text/plain', 'server': 'Protevus3'});
//final log = Logger('ResponseContext');
Completer? _done;
int _statusCode = 200;
/// The [Angel] instance that is sending a response.
Angel? app;
/// The [Protevus] instance that is sending a response.
Protevus? app;
/// Is `Transfer-Encoding` 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].
bool get isOpen;
@ -99,7 +99,7 @@ abstract class ResponseContext<RawResponse>
/// The underlying [RawResponse] under this instance.
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
/// open indefinitely.

View file

@ -21,18 +21,18 @@ import 'service.dart';
//final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
/// A function that configures an [Angel] server.
typedef AngelConfigurer = FutureOr<void> Function(Angel app);
/// A function that configures an [Protevus] server.
typedef Configurer = FutureOr<void> Function(Protevus app);
/// A function that asynchronously generates a view from the given path and data.
typedef ViewGenerator = FutureOr<String> Function(String path,
[Map<String, dynamic>? data]);
/// A function that handles error
typedef AngelErrorHandler = dynamic Function(
typedef PlatformErrorHandler = dynamic Function(
HttpException e, RequestContext req, ResponseContext res);
/// The default error handler for [Angel] server
/// The default error handler for [Protevus] server
Future<bool> _defaultErrorHandler(
HttpException e, RequestContext req, ResponseContext res) async {
if (!req.accepts('text/html', strict: true) &&
@ -78,18 +78,18 @@ Logger _defaultLogger() {
}
/// A powerful real-time/REST/MVC server class.
class Angel extends Routable {
class Protevus extends Routable {
static Future<String> _noViewEngineConfigured(String view, [Map? data]) =>
Future.value('No view engine has been configured yet.');
final List<Angel> _children = [];
final List<Protevus> _children = [];
final Map<
String,
Tuple4<List, Map<String, dynamic>, ParseResult<RouteResult>,
MiddlewarePipeline>> handlerCache = HashMap();
Router<RequestHandler>? _flattened;
Angel? _parent;
Protevus? _parent;
/// A global Map of converters that can transform responses bodies.
final Map<String, Converter<List<int>, List<int>>> encoders = {};
@ -114,20 +114,20 @@ class Angel extends Routable {
bool allowMethodOverrides = true;
/// 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 = {};
/// A set of [Controller] objects that have been loaded into the application.
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.
final AngelEnvironment environment;
final ProtevusEnvironment environment;
/// Returns the parent instance of this application, if any.
Angel? get parent => _parent;
Protevus? get parent => _parent;
/// Outputs diagnostics and debug messages.
Logger _logger = _defaultLogger();
@ -145,12 +145,12 @@ class Angel extends Routable {
/// Plug-ins to be called right before server startup.
///
/// 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.
///
/// 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.
///
@ -163,7 +163,7 @@ class Angel extends Routable {
ViewGenerator? viewGenerator = _noViewEngineConfigured;
/// The handler currently configured to run on [HttpException]s.
AngelErrorHandler errorHandler = _defaultErrorHandler;
PlatformErrorHandler errorHandler = _defaultErrorHandler;
@override
Route<RequestHandler> addRoute(
@ -189,7 +189,7 @@ class Angel extends Routable {
'This route will be ignored, and no requests will ever reach it.');
}
if (router is Angel) {
if (router is Protevus) {
router._parent = this;
_children.add(router);
}
@ -199,11 +199,11 @@ class Angel extends Routable {
/// Loads some base dependencies into the service container.
void bootstrapContainer() {
if (runtimeType != Angel) {
if (runtimeType != Protevus) {
container.registerSingleton(this);
}
container.registerSingleton<Angel>(this);
container.registerSingleton<Protevus>(this);
container.registerSingleton<Routable>(this);
container.registerSingleton<Router>(this);
}
@ -311,7 +311,7 @@ class Angel extends Routable {
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
/// at run-time.
@ -321,7 +321,7 @@ class Angel extends Routable {
void optimizeForProduction({bool force = false}) {
if (environment.isProduction || force == true) {
_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;
}
/// Applies an [AngelConfigurer] to this instance.
Future configure(AngelConfigurer configurer) {
/// Applies an [Configurer] to this instance.
Future configure(Configurer configurer) {
return Future.sync(() => configurer(this));
}
@ -396,10 +396,10 @@ class Angel extends Routable {
'For more, see the documentation:\n'
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
Angel(
Protevus(
{Reflector reflector =
const ThrowingReflector(errorMessage: _reflectionErrorMessage),
this.environment = angelEnv,
this.environment = protevusEnv,
Logger? logger,
this.allowMethodOverrides = true,
this.serializer,
@ -412,7 +412,7 @@ class Angel extends Routable {
if (reflector is EmptyReflector || reflector is ThrowingReflector) {
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);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -64,7 +64,7 @@ Future<RequestContext> acceptContentTypes(
var rq = MockHttpRequest('GET', endpoint, persistentConnection: false);
rq.headers.set('accept', headerString);
rq.close();
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
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';
void main() {
var app = Angel();
var http = AngelHttp(app);
var app = Protevus();
var http = ProtevusHttp(app);
Future<RequestContext> request(
{bool asJson = true,

View file

@ -70,7 +70,7 @@ bool bar(RequestContext req, ResponseContext res) {
}
void main() {
late Angel app;
late Protevus app;
late TodoController todoController;
late NoExposeController noExposeCtrl;
late HttpServer server;
@ -78,7 +78,7 @@ void main() {
String? url;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
app.get(
'/redirect',
(req, res) async =>
@ -104,7 +104,7 @@ void main() {
print(app.controllers);
app.dumpTree();
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.address}:${server.port}';
});
@ -118,20 +118,20 @@ void main() {
});
test('create dynamic handler', () async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
app.get(
'/foo',
ioc(({String? bar}) {
return 2;
}, optional: ['bar']));
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();
expect(json.decode(body), 2);
});
test('optional name', () async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
await app.configure(NamedController().configureServer);
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';
void main() {
late AngelHttp http;
late ProtevusHttp http;
setUp(() async {
var app = Angel();
http = AngelHttp(app);
var app = Protevus();
http = ProtevusHttp(app);
app.get('/detach', (req, res) async {
if (res is HttpResponseContext) {

View file

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

View file

@ -17,10 +17,10 @@ Future<List<int>> getBody(MockHttpResponse rs) async {
}
void main() {
late Angel app;
late Protevus app;
setUp(() {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
app.encoders.addAll(
{
'deflate': zlib.encoder,
@ -40,14 +40,14 @@ void main() {
encodingTests(() => app);
}
void encodingTests(Angel Function() getApp) {
void encodingTests(Protevus Function() getApp) {
group('encoding', () {
Angel app;
late AngelHttp http;
Protevus app;
late ProtevusHttp http;
setUp(() {
app = getApp();
http = AngelHttp(app);
http = ProtevusHttp(app);
});
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';
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(
'default to env or development',
() => expect(AngelEnvironment().value,
() => expect(ProtevusEnvironment().value,
(Platform.environment['ANGEL_ENV'] ?? 'development').toLowerCase()));
test('isDevelopment',
() => expect(AngelEnvironment('development').isDevelopment, true));
test('isStaging', () => expect(AngelEnvironment('staging').isStaging, true));
() => expect(ProtevusEnvironment('development').isDevelopment, true));
test('isStaging',
() => expect(ProtevusEnvironment('staging').isStaging, true));
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) {
var rq = MockHttpRequest('GET', endpoint.replace(path: path))..close();
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
return http.createRequestContext(rq, rq.response);
}

View file

@ -3,18 +3,18 @@ import 'package:test/test.dart';
import 'common.dart';
void main() {
var throwsAnAngelHttpException = throwsA(const IsInstanceOf<HttpException>());
var throwsAnHttpException = throwsA(const IsInstanceOf<HttpException>());
/*
test('throw 404 on null', () {
var service = AnonymousService(index: ([p]) => null);
expect(() => service.findOne(), throwsAnAngelHttpException);
expect(() => service.findOne(), throwsAnHttpException);
});
*/
test('throw 404 on empty iterable', () {
var service = AnonymousService(index: ([p]) => []);
expect(() => service.findOne(), throwsAnAngelHttpException);
expect(() => service.findOne(), throwsAnHttpException);
});
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';
void main() {
late Angel app;
late Protevus app;
late http.Client client;
late HttpServer server;
late String url;
setUp(() async {
app = Angel(reflector: MirrorsReflector())
app = Protevus(reflector: MirrorsReflector())
..post('/foo', (req, res) => res.serialize({'hello': 'world'}))
..all('*', (req, res) => throw HttpException.notFound());
client = http.Client();
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
url = 'http://${server.address.host}:${server.port}';
});

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() {
test('preinjects functions', () async {
var app = Angel(reflector: MirrorsReflector())
var app = Protevus(reflector: MirrorsReflector())
..configuration['foo'] = 'bar'
..get('/foo', ioc(echoAppFoo));
app.optimizeForProduction(force: true);
@ -18,11 +18,11 @@ void main() {
var rq = MockHttpRequest('GET', Uri(path: '/foo'));
await rq.close();
await AngelHttp(app).handleRequest(rq);
await ProtevusHttp(app).handleRequest(rq);
var rs = rq.response;
var body = await rs.transform(utf8.decoder).join();
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;

View file

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

View file

@ -13,10 +13,10 @@ void main() {
}
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'));
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(),
body2 = await rq2.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() {
late http.IOClient client;
late AngelHttp driver;
late ProtevusHttp driver;
late Logger logger;
late StringBuffer buf;
@ -21,14 +21,14 @@ void main() {
..level = Level.ALL
..onRecord.listen(prettyLog);
var app = Angel(logger: logger);
var app = Protevus(logger: logger);
app.fallback((req, res) {
req.shutdownHooks.add(() => buf.write('Hello, '));
req.shutdownHooks.add(() => buf.write('world!'));
});
driver = AngelHttp(app);
driver = ProtevusHttp(app);
await driver.startServer();
});

View file

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

View file

@ -36,16 +36,16 @@ bool interceptService(RequestContext req, ResponseContext res) {
}
void main() {
late Angel app;
late Angel nested;
late Angel todos;
late Protevus app;
late Protevus nested;
late Protevus todos;
late String url;
late http.Client client;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
nested = Angel(reflector: MirrorsReflector());
todos = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
nested = Protevus(reflector: MirrorsReflector());
todos = Protevus(reflector: MirrorsReflector());
for (var app in [app, nested, todos]) {
app.logger = Logger('routing_test')
@ -113,7 +113,7 @@ void main() {
//app.dumpTree(header: "DUMPING ROUTES:", showMatchers: true);
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}';
});
@ -141,13 +141,13 @@ void main() {
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 json_ = json.decode(response.body);
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 json_ = json.decode(response.body);
print('JSON: $json_');
@ -184,9 +184,9 @@ void main() {
test('Can name routes', () {
Route foo = app.get('/framework/:id', null)..name = 'frm';
print('Foo: $foo');
String uri = foo.makeUri({'id': 'angel'});
String uri = foo.makeUri({'id': 'Protevus'});
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';
void main() {
late Angel app;
late Protevus app;
late http.Client client;
late HttpServer server;
late String url;
setUp(() async {
app = Angel(reflector: MirrorsReflector())
app = Protevus(reflector: MirrorsReflector())
..get('/foo', ioc(() => {'hello': 'world'}))
..get('/bar', (req, res) async {
await res.serialize({'hello': 'world'},
@ -22,7 +22,7 @@ void main() {
});
client = http.Client();
server = await AngelHttp(app).startServer();
server = await ProtevusHttp(app).startServer();
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
void main() {
group('scoping', () {
var parent = Angel(reflector: MirrorsReflector())..configuration['two'] = 2;
var child = Angel(reflector: MirrorsReflector());
var parent = Protevus(reflector: MirrorsReflector())
..configuration['two'] = 2;
var child = Protevus(reflector: MirrorsReflector());
parent.mount('/child', child);
test('sets children', () {
@ -32,14 +33,14 @@ void main() {
});
test('custom server generator', () {
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp.custom(app, HttpServer.bind);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp.custom(app, HttpServer.bind);
expect(http.serverGenerator, HttpServer.bind);
});
test('default error handler', () async {
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
var rq = MockHttpRequest('GET', $foo);
await (rq.close());
var rs = rq.response;
@ -61,10 +62,10 @@ void main() {
});
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);
var http = AngelHttp(app);
var http = ProtevusHttp(app);
await http.startServer();
expect(app.configuration['two'], 2);
await app.close();
@ -72,7 +73,7 @@ void main() {
});
test('warning when adding routes to flattened router', () {
var app = Angel(reflector: MirrorsReflector())
var app = Protevus(reflector: MirrorsReflector())
..optimizeForProduction(force: true);
app.dumpTree();
app.get('/', (req, res) => 2);
@ -80,7 +81,7 @@ void main() {
});
test('services close on close call', () async {
var app = Angel(reflector: MirrorsReflector());
var app = Protevus(reflector: MirrorsReflector());
var svc = CustomCloseService();
expect(svc.value, 2);
app.use('/', svc);
@ -89,8 +90,8 @@ void main() {
});
test('global injection added to injection map', () async {
var app = Angel(reflector: MirrorsReflector())..configuration['a'] = 'b';
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector())..configuration['a'] = 'b';
var http = ProtevusHttp(app);
app.get('/', ioc((String a) => a));
var rq = MockHttpRequest('GET', Uri.parse('/'));
await (rq.close());
@ -100,8 +101,8 @@ void main() {
});
test('global injected serializer', () async {
var app = Angel(reflector: MirrorsReflector())..serializer = (_) => 'x';
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector())..serializer = (_) => 'x';
var http = ProtevusHttp(app);
app.get($foo.path, (req, ResponseContext res) => res.serialize(null));
var rq = MockHttpRequest('GET', $foo);
await (rq.close());
@ -111,8 +112,8 @@ void main() {
});
group('handler results', () {
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
var app = Protevus(reflector: MirrorsReflector());
var http = ProtevusHttp(app);
app.responseFinalizers.add((req, res) => throw HttpException.forbidden());
late RequestContext req;
late ResponseContext res;
@ -153,14 +154,14 @@ void main() {
});
group('handleHttpException', () {
late Angel app;
late AngelHttp http;
late Protevus app;
late ProtevusHttp http;
setUp(() async {
app = Angel(reflector: MirrorsReflector());
app = Protevus(reflector: MirrorsReflector());
app.get('/wtf', (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);
var oldHandler = app.errorHandler;

View file

@ -16,20 +16,20 @@ void main() {
'Accept': 'application/json',
'Content-Type': 'application/json'
};
late Angel app;
late Protevus app;
late MapService service;
late String url;
late http.Client client;
setUp(() async {
app = Angel(reflector: MirrorsReflector())
app = Protevus(reflector: MirrorsReflector())
..use('/todos', service = MapService())
..errorHandler = (e, req, res) {
if (e.error != null) print('Whoops: ${e.error}');
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();
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;
void main() {
late Angel app;
late AngelHttp http;
late Protevus app;
late ProtevusHttp http;
setUp(() {
app = Angel(reflector: MirrorsReflector());
http = AngelHttp(app, useZone: true);
app = Protevus(reflector: MirrorsReflector());
http = ProtevusHttp(app, useZone: true);
app.logger = Logger('streaming_test')
..onRecord.listen((rec) {

View file

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

View file

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

View file

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