platform/incubation/container/container
2024-12-26 23:25:59 -07:00
..
doc refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
example refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
lib refactor: adding support for class@method syntax 2024-12-26 23:25:59 -07:00
test refactor: adding support for class@method syntax 2024-12-26 23:25:59 -07:00
.gitignore refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
analysis_options.yaml refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
AUTHORS.md refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
CHANGELOG.md refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
LICENSE refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
pubspec.yaml refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -07:00
README.md refactor: working on container test 3 82 pass 2 fail 2024-12-26 21:28:51 -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_foundation/core.dart';
    import 'package:platform_foundation/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}");
    }