ioc function
Shortcut for calling preInject, and then handleContained.
Use this to instantly create a request handler for a DI-enabled method.
Calling ioc also auto-serializes the result of a handler
.
Implementation
RequestHandler ioc(Function handler, {Iterable<String> optional = const []}) {
InjectionRequest injection;
RequestHandler contained;
return (req, res) {
if (injection == null) {
injection = preInject(handler, req.app.container.reflector);
injection.optional.addAll(optional ?? []);
contained = handleContained(handler, injection);
}
return req.app.executeHandler(contained, req, res);
};
}