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