platform/packages/container/angel_container
2024-06-23 12:09:26 +08:00
..
example Fixed requireAuthentication 2021-10-04 13:13:56 +08:00
lib Fixed analyze issues 2024-05-22 00:32:59 +08:00
test Upgraded lints to 3.0.0 2023-12-24 09:52:57 +08:00
.gitignore Publish angel3_container 2021-05-14 15:41:25 +08:00
analysis_options.yaml Updated auth, model, container and its generator 2021-09-26 14:53:42 +08:00
AUTHORS.md Publish angel3_container 2021-05-14 15:41:25 +08:00
CHANGELOG.md Updated to support SDK 3.3.0 2024-06-23 12:09:26 +08:00
LICENSE Updated auth, model, container and its generator 2021-09-26 14:53:42 +08:00
melos_angel3_container.iml Added melos 2022-03-19 09:37:28 +08:00
pubspec.yaml Updated to support SDK 3.3.0 2024-06-23 12:09:26 +08:00
README.md Updated repository links 2023-12-25 11:45:10 +08:00

Angel3 Container

Pub Version (including pre-releases) Null Safety Gitter 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}");
    }