This commit is contained in:
2023-04-24 10:54:56 +08:00
parent a8285848d8
commit 01718f99ed
6 changed files with 148 additions and 160 deletions
+23
View File
@@ -8,7 +8,12 @@ use Kiri\Di\Context;
use Kiri\Router\Constrict\ConstrictResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use ReflectionException;
/**
*
*/
class Response implements ResponseInterface
{
@@ -19,6 +24,24 @@ class Response implements ResponseInterface
public ContentType $contentType = ContentType::JSON;
/**
* @var string|SwooleHttpResponseEmitterInterface
*/
public string|SwooleHttpResponseEmitterInterface $emmit = SwooleHttpResponseEmitterInterface::class;
/**
* @return void
* @throws ReflectionException
*/
public function init(): void
{
if (is_string($this->emmit)) {
$this->emmit = di($this->emmit);
}
}
/**
* @param ContentType $contentType
* @return Response