改名
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Http;
|
||||
|
||||
use Annotation\Inject;
|
||||
use Exception;
|
||||
use HttpServer\Abstracts\HttpService;
|
||||
use HttpServer\IInterface\AuthIdentity;
|
||||
@@ -36,8 +37,18 @@ class Request extends HttpService
|
||||
|
||||
public int $fd = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @var HttpParams|null
|
||||
*/
|
||||
#[Inject(HttpParams::class)]
|
||||
public ?HttpParams $params = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var HttpHeaders|null
|
||||
*/
|
||||
#[Inject(HttpHeaders::class)]
|
||||
public ?HttpHeaders $headers = null;
|
||||
|
||||
public bool $isCli = FALSE;
|
||||
@@ -440,20 +451,14 @@ class Request extends HttpService
|
||||
* @return Request
|
||||
* @throws ReflectionException
|
||||
* @throws NotFindClassException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function create(\Swoole\Http\Request $request): Request
|
||||
{
|
||||
$request->header = array_merge($request->header, $request->server);
|
||||
Context::setContext('request', $request);
|
||||
/** @var Request $sRequest */
|
||||
$sRequest = Snowflake::getDi()->get(Request::class);
|
||||
if ($sRequest->headers === null) {
|
||||
$sRequest->headers = di(HttpHeaders::class);
|
||||
}
|
||||
if ($sRequest->params === null) {
|
||||
$sRequest->params = di(HttpParams::class);
|
||||
}
|
||||
return $sRequest;
|
||||
return Snowflake::app()->get('request');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace HttpServer;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Server\ServerManager;
|
||||
use Snowflake\Abstracts\Component;
|
||||
|
||||
|
||||
@@ -48,7 +49,8 @@ class Shutdown extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$master_pid = Server()->setting['pid_file'] ?? PID_PATH;
|
||||
$server = ServerManager::getContext()->getServer();
|
||||
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
||||
if (file_exists($master_pid)) {
|
||||
$this->close(file_get_contents($master_pid));
|
||||
}
|
||||
@@ -75,7 +77,8 @@ class Shutdown extends Component
|
||||
*/
|
||||
public function isRunning(): bool
|
||||
{
|
||||
$master_pid = Server()->setting['pid_file'] ?? PID_PATH;
|
||||
$server = ServerManager::getContext()->getServer();
|
||||
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
||||
|
||||
if (!file_exists($master_pid)) {
|
||||
return false;
|
||||
|
||||
+2
-16
@@ -388,7 +388,7 @@ if (!function_exists('trim_blank')) {
|
||||
* @param bool $htmlTags
|
||||
* @return array|string|null
|
||||
*/
|
||||
function trim_blank(string $content, $len = 0, $encode = 'utf-8', $htmlTags = true): array|string|null
|
||||
function trim_blank(string $content, int $len = 0, string $encode = 'utf-8', bool $htmlTags = true): array|string|null
|
||||
{
|
||||
$str = trim($content);
|
||||
if ($htmlTags) {
|
||||
@@ -505,20 +505,6 @@ if (!function_exists('Input')) {
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('Server')) {
|
||||
|
||||
|
||||
/**
|
||||
* @return Http|Packet|Receive|Websocket|null
|
||||
* @throws Exception
|
||||
*/
|
||||
function Server(): Http|Packet|Receive|Websocket|null
|
||||
{
|
||||
return Snowflake::app()->getSwoole();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('storage')) {
|
||||
|
||||
/**
|
||||
@@ -527,7 +513,7 @@ if (!function_exists('storage')) {
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function storage($fileName = '', $path = ''): string
|
||||
function storage(string $fileName = '', string $path = ''): string
|
||||
{
|
||||
|
||||
$basePath = rtrim(Snowflake::getStoragePath(), '/');
|
||||
|
||||
Reference in New Issue
Block a user