改名
This commit is contained in:
@@ -41,26 +41,7 @@ class OnRequest extends Callback
|
||||
if ($sRequest->is('favicon.ico')) {
|
||||
return $params = $sResponse->send($sRequest->isNotFound(), 200);
|
||||
}
|
||||
|
||||
register_shutdown_function(OnRequest::class . '::shutdown', $response);
|
||||
return $params = Snowflake::app()->getRouter()->dispatch();
|
||||
} catch (Error | \Throwable $exception) {
|
||||
$params = $this->sendErrorMessage($sResponse ?? null, $exception, $response);
|
||||
} finally {
|
||||
$events = Snowflake::app()->getEvent();
|
||||
if (!$events->exists(Event::EVENT_AFTER_REQUEST)) {
|
||||
return;
|
||||
}
|
||||
$events->trigger(Event::EVENT_AFTER_REQUEST, [$sRequest, $params]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $response
|
||||
*/
|
||||
public static function shutdown($response)
|
||||
{
|
||||
register_shutdown_function(function ($response) {
|
||||
$error = error_get_last();
|
||||
if (!isset($error['type'])) {
|
||||
return;
|
||||
@@ -74,6 +55,17 @@ class OnRequest extends Callback
|
||||
$response->end($error['message']);
|
||||
}
|
||||
unset($response);
|
||||
}, $response);
|
||||
return $params = Snowflake::app()->getRouter()->dispatch();
|
||||
} catch (Error | \Throwable $exception) {
|
||||
$params = $this->sendErrorMessage($sResponse ?? null, $exception, $response);
|
||||
} finally {
|
||||
$events = Snowflake::app()->getEvent();
|
||||
if (!$events->exists(Event::EVENT_AFTER_REQUEST)) {
|
||||
return;
|
||||
}
|
||||
$events->trigger(Event::EVENT_AFTER_REQUEST, [$sRequest, $params]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user