This commit is contained in:
2021-10-25 18:25:14 +08:00
parent 6605aae410
commit a9d106a1cf
48 changed files with 5090 additions and 0 deletions
@@ -0,0 +1,16 @@
<?php
namespace Http\Abstracts;
use Annotation\Inject;
use Kiri\Events\EventDispatch;
trait EventDispatchHelper
{
/** @var EventDispatch */
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
}
@@ -0,0 +1,23 @@
<?php
namespace Http\Abstracts;
use Http\Constrict\Response;
use Throwable;
use Http\Constrict\ResponseInterface;
/**
*
*/
interface ExceptionHandlerInterface
{
/**
* @param Throwable $exception
* @param Response $response
* @return ResponseInterface
*/
public function emit(Throwable $exception, Response $response): ResponseInterface;
}
@@ -0,0 +1,23 @@
<?php
namespace Http\Abstracts;
use JetBrains\PhpStorm\Pure;
/**
*
*/
class PageNotFoundException extends \Exception
{
/**
*
*/
#[Pure] public function __construct(int $code)
{
parent::__construct('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', $code);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Http\Abstracts;
use Annotation\Inject;
use Http\Constrict\Emitter;
use Http\Constrict\Response as CResponse;
/**
*
*/
trait ResponseHelper
{
/** @var CResponse|mixed */
#[Inject(CResponse::class)]
public CResponse $response;
public Emitter $responseEmitter;
}