public function __invoke(Request $request, Response $response)
{
foreach ($this->applications as $action) {
$out = $action($request, $response);
if ($out instanceof \Generator) {
yield from $out;
}
if ($response->state() & Response::STARTED) {
return;
}
if ($this->isStopping) {
$response->setStatus(HTTP_STATUS["SERVICE_UNAVAILABLE"]);
$response->setReason("Server shutting down");
$response->setHeader("Aerys-Generic-Response", "enable");
$response->end();
return;
}
}
}