platform/core/container/container
2024-10-02 19:17:17 -07:00
..
example Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
lib Add: support for registerTransient, registerScoped and registerConstant 2024-10-02 19:17:17 -07:00
test Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
.gitignore Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
analysis_options.yaml Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
AUTHORS.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
CHANGELOG.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
LICENSE Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
pubspec.yaml Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
README.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00

Angel3 Container

Pub Version (including pre-releases) Null Safety Discord License

A better IoC container for Angel3, ultimately allowing Angel3 to be used with or without dart:mirrors package.

    import 'package:angel3_container/mirrors.dart';
    import 'package:angel3_framework/angel3_framework.dart';
    import 'package:angel3_framework/http.dart';

    @Expose('/sales', middleware: [process1])
    class SalesController extends Controller {
        @Expose('/', middleware: [process2])
        Future<String> route1(RequestContext req, ResponseContext res) async {
            return "Sales route";
        }
    }

    bool process1(RequestContext req, ResponseContext res) {
        res.write('Hello, ');
        return true;
    }

    bool process2(RequestContext req, ResponseContext res) {
        res.write('From Sales, ');
        return true;
    }

    void main() async {
        // Using Mirror Reflector
        var app = Angel(reflector: MirrorsReflector());

        // Sales Controller
        app.container.registerSingleton<SalesController>(SalesController());
        await app.mountController<SalesController>();

        var http = AngelHttp(app);
        var server = await http.startServer('localhost', 3000);
        print("Angel3 server listening at ${http.uri}");
    }