platform/packages/container/angel_container
Patrick Stewart e4775d1ea9
Some checks are pending
Angel3 CI / Validate framework package (push) Waiting to run
Angel3 CI / Validate ORM packages (push) Waiting to run
Remove: deleting melos jetbrains artifacts
2024-10-01 20:11:25 -07: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
pubspec.yaml Updated to support SDK 3.3.0 2024-06-23 12:09:26 +08:00
README.md Replaced Gitter with Discord chat 2024-07-07 23:02:49 +08: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}");
    }