platform/packages/container/container
2024-10-20 11:50:07 -07:00
..
example update(angel3): refactoring and adding api inline help 2024-09-24 21:04:57 -07:00
lib update: results from dart format 2024-10-20 11:50:07 -07:00
test update(angel3): refactoring and adding api inline help 2024-09-24 21:04:57 -07:00
.gitignore add(angel3): adding re-branded angel3 container package 2024-09-22 18:43:11 -07:00
analysis_options.yaml add(angel3): adding re-branded angel3 container package 2024-09-22 18:43:11 -07:00
AUTHORS.md add(angel3): adding re-branded angel3 container package 2024-09-22 18:43:11 -07:00
CHANGELOG.md add(angel3): adding re-branded angel3 container package 2024-09-22 18:43:11 -07:00
LICENSE add(angel3): adding re-branded angel3 container package 2024-09-22 18:43:11 -07:00
pubspec.yaml update(angel3): updating pubspec files 2024-09-23 13:56:10 -07:00
README.md update(angel3): rebranding angel3 2024-09-28 16:14:48 -07:00

Protevus Container

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

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

    import 'package:platform_container/mirrors.dart';
    import 'package:platform_core/core.dart';
    import 'package:platform_core/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 = Protevus(reflector: MirrorsReflector());

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

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