改名
This commit is contained in:
@@ -194,15 +194,11 @@ class Response extends HttpService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $content
|
* @param mixed $content
|
||||||
* @param int $statusCode
|
|
||||||
* @param null $format
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function setContent(mixed $content, int $statusCode = 200, $format = null): static
|
public function setContent(mixed $content): static
|
||||||
{
|
{
|
||||||
$this->endData = $content;
|
$this->endData = $content;
|
||||||
$this->setStatusCode($statusCode);
|
|
||||||
$this->setFormat($format);
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ use Annotation\Inject;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Exception\RequestException;
|
use HttpServer\Exception\RequestException;
|
||||||
use HttpServer\Http\Request as HSRequest;
|
use HttpServer\Http\Request as HSRequest;
|
||||||
use Server\Constrict\Response as CResponse;
|
|
||||||
use HttpServer\Route\Node;
|
use HttpServer\Route\Node;
|
||||||
use HttpServer\Route\Router;
|
use HttpServer\Route\Router;
|
||||||
|
use Server\Constrict\Response as CResponse;
|
||||||
use Server\Events\OnAfterRequest;
|
use Server\Events\OnAfterRequest;
|
||||||
use Snowflake\Events\EventDispatch;
|
use Snowflake\Events\EventDispatch;
|
||||||
use Swoole\Error;
|
use Swoole\Error;
|
||||||
@@ -95,12 +95,11 @@ class HTTPServerListener extends Abstracts\Server
|
|||||||
if (!($node instanceof Node)) {
|
if (!($node instanceof Node)) {
|
||||||
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
||||||
}
|
}
|
||||||
$responseData = $this->response->setContent($node->dispatch(),200);
|
$responseData = $this->response->setContent($node->dispatch())->setStatusCode(200);
|
||||||
} catch (Error | Throwable $exception) {
|
} catch (Error | Throwable $exception) {
|
||||||
$code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
$code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
||||||
$data = $code == 404 ? $exception->getMessage() : jTraceEx($exception);
|
$data = $code == 404 ? $exception->getMessage() : jTraceEx($exception);
|
||||||
|
$responseData = $this->response->setContent($data)->setFormat(CResponse::HTML)->setStatusCode($code);
|
||||||
$responseData = $this->response->setContent($data, $code, CResponse::HTML);
|
|
||||||
} finally {
|
} finally {
|
||||||
$response->end($responseData->configure($response)->getContent());
|
$response->end($responseData->configure($response)->getContent());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user