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 []}) {
return (req, res) {
RequestHandler? contained;
if (req.app?.container != null) {
var injection = preInject(handler, req.app!.container!.reflector);
//if (injection != null) {
injection.optional.addAll(optional);
contained = handleContained(handler, injection);
//}
}
return req.app!.executeHandler(contained, req, res);
};
}