改名
This commit is contained in:
@@ -15,8 +15,9 @@ use HttpServer\Http\Formatter\HtmlFormatter;
|
||||
use HttpServer\Http\Formatter\JsonFormatter;
|
||||
use HttpServer\Http\Formatter\XmlFormatter;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Core\Help;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Http\Response as SResponse;
|
||||
use Swoole\Http2\Response as S2Response;
|
||||
@@ -151,18 +152,20 @@ class Response extends HttpService
|
||||
/**
|
||||
* @param string $context
|
||||
* @param int $statusCode
|
||||
* @param null $response
|
||||
* @param null $appointResponse
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send($context = '', $statusCode = 200, $response = null): mixed
|
||||
public function send($context = '', $statusCode = 200, $appointResponse = null): mixed
|
||||
{
|
||||
$sendData = $this->parseData($context);
|
||||
if ($response instanceof SResponse) {
|
||||
$this->response = $response;
|
||||
|
||||
$response = Context::getContext('response');
|
||||
if ($appointResponse instanceof SResponse) {
|
||||
$response = $appointResponse;
|
||||
}
|
||||
if ($this->response instanceof SResponse) {
|
||||
$this->sendData($this->response, $sendData, $statusCode);
|
||||
if ($response instanceof SResponse) {
|
||||
$this->sendData($response, $sendData, $statusCode);
|
||||
} else {
|
||||
if (!empty(request()->fd)) {
|
||||
return '';
|
||||
@@ -247,7 +250,9 @@ class Response extends HttpService
|
||||
|
||||
|
||||
/**
|
||||
* @param $response
|
||||
* @param $status
|
||||
* @return Response
|
||||
*/
|
||||
private function setHeaders($response, $status): static
|
||||
{
|
||||
@@ -285,15 +290,18 @@ class Response extends HttpService
|
||||
|
||||
/**
|
||||
* @param null $response
|
||||
* @return mixed
|
||||
* @return static
|
||||
* @throws ReflectionException
|
||||
* @throws NotFindClassException
|
||||
*/
|
||||
public static function create($response = null): static
|
||||
{
|
||||
$ciResponse = new Response();
|
||||
Context::setContext('response', $response);
|
||||
|
||||
$ciResponse = Snowflake::createObject(Response::class);
|
||||
$ciResponse->response = $response;
|
||||
$ciResponse->startTime = microtime(true);
|
||||
$ciResponse->format = self::JSON;
|
||||
Context::setContext('response', $ciResponse);
|
||||
return $ciResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ declare(strict_types=1);
|
||||
namespace Snowflake\Abstracts;
|
||||
|
||||
|
||||
use Annotation\Annotation as SAnnotation;
|
||||
use Exception;
|
||||
use HttpServer\Client\Http2;
|
||||
use HttpServer\Http\Request;
|
||||
use HttpServer\Http\Response;
|
||||
use HttpServer\HttpFilter;
|
||||
use HttpServer\Route\Router;
|
||||
use HttpServer\Server;
|
||||
|
||||
use HttpServer\Service\Http;
|
||||
use HttpServer\Service\Packet;
|
||||
use HttpServer\Service\Receive;
|
||||
@@ -23,7 +25,6 @@ use HttpServer\Service\Websocket;
|
||||
use HttpServer\Shutdown;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kafka\Producer;
|
||||
use Annotation\Annotation as SAnnotation;
|
||||
use Kafka\TaskContainer;
|
||||
use ReflectionException;
|
||||
use Snowflake\Aop;
|
||||
@@ -33,14 +34,14 @@ use Snowflake\Channel;
|
||||
use Snowflake\Di\Service;
|
||||
use Snowflake\Error\ErrorHandler;
|
||||
use Snowflake\Error\Logger;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\InitException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Jwt\Jwt;
|
||||
use Snowflake\Pool\Connection;
|
||||
use Snowflake\Pool\Pool as SPool;
|
||||
use Snowflake\Pool\Redis as SRedis;
|
||||
use Snowflake\Snowflake;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Pool\Pool as SPool;
|
||||
use Swoole\Table;
|
||||
|
||||
/**
|
||||
@@ -457,6 +458,8 @@ abstract class BaseApplication extends Service
|
||||
'kafka-container' => ['class' => TaskContainer::class],
|
||||
'filter' => ['class' => HttpFilter::class],
|
||||
'goto' => ['class' => BaseGoto::class],
|
||||
'response' => ['class' => Response::class],
|
||||
'request' => ['class' => Request::class],
|
||||
'channel' => ['class' => Channel::class],
|
||||
'rpc' => ['class' => \Rpc\Producer::class],
|
||||
'rpc-service' => ['class' => \Rpc\Service::class],
|
||||
|
||||
Reference in New Issue
Block a user