platform/packages/container/angel_container
2023-05-20 15:39:47 +00:00
..
example Fixed requireAuthentication 2021-10-04 13:13:56 +08:00
lib Fixed EmptyReflector 2023-04-15 11:05:33 +08:00
test Fixed requireAuthentication 2021-10-04 13:13:56 +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 Fixed EmptyReflector 2023-04-15 11:05:33 +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 Dart 3 2023-05-20 15:39:47 +00:00
README.md Updated README 2023-04-15 09:09:23 +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("Angel server listening at ${http.uri}");
    }