改名
This commit is contained in:
@@ -10,6 +10,7 @@ use HttpServer\Exception\ExitException;
|
|||||||
use HttpServer\Http\Request as HRequest;
|
use HttpServer\Http\Request as HRequest;
|
||||||
use HttpServer\Http\Response as HResponse;
|
use HttpServer\Http\Response as HResponse;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use Snowflake\Core\Json;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
@@ -32,22 +33,21 @@ class OnRequest extends Callback
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onHandler(Request $request, Response $response)
|
public function onHandler(Request $request, Response $response): mixed
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
[$req, $rep] = static::create($request, $response);
|
[$req, $rep] = static::create($request, $response);
|
||||||
if ($req->is('favicon.ico')) {
|
if ($req->is('favicon.ico')) {
|
||||||
\send(null, 404);
|
return \send(null, 404);
|
||||||
} else {
|
|
||||||
\router()->dispatch();
|
|
||||||
}
|
}
|
||||||
|
\router()->dispatch();
|
||||||
} catch (ExitException | Error | \Throwable $exception) {
|
} catch (ExitException | Error | \Throwable $exception) {
|
||||||
if ($exception instanceof ExitException) {
|
if ($exception instanceof ExitException) {
|
||||||
\send($exception->getMessage(), $exception->getCode());
|
return \send($exception->getMessage(), $exception->getCode());
|
||||||
} else {
|
|
||||||
$this->sendErrorMessage($exception);
|
|
||||||
}
|
}
|
||||||
|
$this->sendErrorMessage($exception);
|
||||||
} finally {
|
} finally {
|
||||||
|
write(Json::encode(get_object_vars($request)), 'request');
|
||||||
$this->onAfter();
|
$this->onAfter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user