改名
This commit is contained in:
@@ -12,10 +12,12 @@ use HttpServer\Http\Request as HRequest;
|
|||||||
use HttpServer\Http\Response as HResponse;
|
use HttpServer\Http\Response as HResponse;
|
||||||
use HttpServer\Route\Node;
|
use HttpServer\Route\Node;
|
||||||
use HttpServer\Service\Http;
|
use HttpServer\Service\Http;
|
||||||
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Core\JSON;
|
use Snowflake\Core\JSON;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Error;
|
use Swoole\Error;
|
||||||
@@ -55,12 +57,12 @@ class OnRequest extends Callback
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/** @var HRequest $sRequest */
|
/** @var HRequest $sRequest */
|
||||||
[$sRequest, $sResponse] = [HRequest::create($request), HResponse::create($response)];
|
[$sRequest, $sResponse] = $this->create($request, $response);
|
||||||
|
|
||||||
if ($sRequest->is('favicon.ico')) {
|
if ($sRequest->is('favicon.ico')) {
|
||||||
return $sResponse->send($sRequest->isNotFound(), 200);
|
return $sResponse->send($sRequest->isNotFound(), 200);
|
||||||
|
} else {
|
||||||
|
return Snowflake::app()->getRouter()->dispatch();
|
||||||
}
|
}
|
||||||
return Snowflake::app()->getRouter()->dispatch();
|
|
||||||
} catch (ExitException $exception) {
|
} catch (ExitException $exception) {
|
||||||
return send($exception->getMessage(), $exception->getCode());
|
return send($exception->getMessage(), $exception->getCode());
|
||||||
} catch (Error | \Throwable $exception) {
|
} catch (Error | \Throwable $exception) {
|
||||||
@@ -75,6 +77,19 @@ class OnRequest extends Callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $request
|
||||||
|
* @param $response
|
||||||
|
* @return array
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
private function create($request, $response): array
|
||||||
|
{
|
||||||
|
return [HRequest::create($request), HResponse::create($response)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $response
|
* @param $response
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user