改名
This commit is contained in:
@@ -7,6 +7,7 @@ namespace HttpServer\Events;
|
|||||||
use Annotation\Route\Socket;
|
use Annotation\Route\Socket;
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Abstracts\Callback;
|
use HttpServer\Abstracts\Callback;
|
||||||
|
use HttpServer\Http\HttpParams;
|
||||||
use HttpServer\Http\Request;
|
use HttpServer\Http\Request;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
@@ -119,10 +120,14 @@ class OnHandshake extends Callback
|
|||||||
}
|
}
|
||||||
$router = Snowflake::app()->getRouter();
|
$router = Snowflake::app()->getRouter();
|
||||||
|
|
||||||
|
/** @var Request $sRequest */
|
||||||
$sRequest = Request::create($request);
|
$sRequest = Request::create($request);
|
||||||
$sRequest->uri = '/' . Socket::HANDSHAKE . '::event';
|
$sRequest->uri = '/' . Socket::HANDSHAKE . '::event';
|
||||||
$sRequest->headers->replace('request_method', 'sw::socket');
|
$sRequest->headers->replace('request_method', 'sw::socket');
|
||||||
$sRequest->headers->replace('request_uri', $sRequest->uri);
|
$sRequest->headers->replace('request_uri', $sRequest->uri);
|
||||||
|
|
||||||
|
$sRequest->params = new HttpParams();
|
||||||
|
|
||||||
$sRequest->parseUri();
|
$sRequest->parseUri();
|
||||||
|
|
||||||
if (($node = $router->find_path($sRequest)) === null) {
|
if (($node = $router->find_path($sRequest)) === null) {
|
||||||
|
|||||||
@@ -33,17 +33,20 @@ class HttpParams
|
|||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private array $files = [];
|
private array $files = [];
|
||||||
|
private array $socket = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpParams constructor.
|
* HttpParams constructor.
|
||||||
* @param $body
|
* @param $body
|
||||||
* @param $get
|
* @param $get
|
||||||
* @param $files
|
* @param $files
|
||||||
|
* @param array $socket
|
||||||
*/
|
*/
|
||||||
public function __construct($body, $get, $files)
|
public function __construct($body, $get, $files, $socket = [])
|
||||||
{
|
{
|
||||||
$this->gets = $get ?? [];
|
$this->gets = $get ?? [];
|
||||||
$this->files = $files ?? [];
|
$this->files = $files ?? [];
|
||||||
|
$this->socket = $socket ?? [];
|
||||||
if (!is_array($body)) {
|
if (!is_array($body)) {
|
||||||
$this->body = Help::toArray($body);
|
$this->body = Help::toArray($body);
|
||||||
} else {
|
} else {
|
||||||
@@ -172,7 +175,7 @@ class HttpParams
|
|||||||
*/
|
*/
|
||||||
#[Pure] public function load(): array
|
#[Pure] public function load(): array
|
||||||
{
|
{
|
||||||
return array_merge($this->files ?? [], $this->body ?? [], $this->gets ?? []);
|
return array_merge($this->files ?? [], $this->body ?? [], $this->gets ?? [], $this->socket ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -571,9 +571,6 @@ class Node extends HttpService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ComponentException
|
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function httpFilter(): mixed
|
private function httpFilter(): mixed
|
||||||
@@ -589,6 +586,8 @@ class Node extends HttpService
|
|||||||
$filter = Snowflake::app()->get('filter');
|
$filter = Snowflake::app()->get('filter');
|
||||||
$validator = $filter->check(get_class($class), $method);
|
$validator = $filter->check(get_class($class), $method);
|
||||||
if ($validator instanceof Validator && !$validator->validation()) {
|
if ($validator instanceof Validator && !$validator->validation()) {
|
||||||
|
response()->statusCode = 401;
|
||||||
|
|
||||||
return Json::to(401, $validator->getError());
|
return Json::to(401, $validator->getError());
|
||||||
}
|
}
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
|
|||||||
Reference in New Issue
Block a user