改名
This commit is contained in:
@@ -14,6 +14,7 @@ use HttpServer\Abstracts\HttpService;
|
|||||||
use HttpServer\Http\Formatter\HtmlFormatter;
|
use HttpServer\Http\Formatter\HtmlFormatter;
|
||||||
use HttpServer\Http\Formatter\JsonFormatter;
|
use HttpServer\Http\Formatter\JsonFormatter;
|
||||||
use HttpServer\Http\Formatter\XmlFormatter;
|
use HttpServer\Http\Formatter\XmlFormatter;
|
||||||
|
use Server\ResponseInterface;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Swoole\Http\Response as SResponse;
|
use Swoole\Http\Response as SResponse;
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ use Swoole\Http\Response as SResponse;
|
|||||||
* Class Response
|
* Class Response
|
||||||
* @package Snowflake\Snowflake\Http
|
* @package Snowflake\Snowflake\Http
|
||||||
*/
|
*/
|
||||||
class Response extends HttpService
|
class Response extends HttpService implements ResponseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
const JSON = 'json';
|
const JSON = 'json';
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Server\Constrict;
|
|||||||
|
|
||||||
use HttpServer\Http\Context;
|
use HttpServer\Http\Context;
|
||||||
use HttpServer\Http\Response as HttpResponse;
|
use HttpServer\Http\Response as HttpResponse;
|
||||||
|
use Server\ResponseInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +14,7 @@ use HttpServer\Http\Response as HttpResponse;
|
|||||||
* @package Server
|
* @package Server
|
||||||
* @mixin HttpResponse
|
* @mixin HttpResponse
|
||||||
*/
|
*/
|
||||||
class Response
|
class Response implements ResponseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
const JSON = 'json';
|
const JSON = 'json';
|
||||||
|
|||||||
@@ -121,7 +121,9 @@ 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);
|
||||||
}
|
}
|
||||||
|
if (!(($responseData = $node->dispatch()) instanceof ResponseInterface)) {
|
||||||
$responseData = $this->response->setContent($node->dispatch())->setStatusCode(200);
|
$responseData = $this->response->setContent($node->dispatch())->setStatusCode(200);
|
||||||
|
}
|
||||||
} catch (Error | Throwable $exception) {
|
} catch (Error | Throwable $exception) {
|
||||||
$responseData = $this->exceptionHandler->emit($exception, $this->response);
|
$responseData = $this->exceptionHandler->emit($exception, $this->response);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Server;
|
||||||
|
|
||||||
|
interface ResponseInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user