This commit is contained in:
2023-09-15 15:58:24 +08:00
parent 779cccd331
commit 3d6099ea6e
2 changed files with 5 additions and 6 deletions
+2 -4
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Kiri\Router\Base; namespace Kiri\Router\Base;
use Kiri\Di\Context;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
class NotFoundController extends Controller class NotFoundController extends Controller
@@ -16,11 +15,10 @@ class NotFoundController extends Controller
*/ */
public function fail(): ResponseInterface public function fail(): ResponseInterface
{ {
$response = Context::get(ResponseInterface::class);
if ($this->request->getMethod() == 'OPTIONS') { if ($this->request->getMethod() == 'OPTIONS') {
return $response->withStatus(200, ""); return \response()->withStatus(200, "empty content");
} else { } else {
return $response->withStatus(404, "not found page."); return \response()->withStatus(404, "not found page.");
} }
} }
+3 -2
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Kiri\Router; namespace Kiri\Router;
use Closure; use Closure;
use Kiri\Di\Context;
use Kiri\Router\Constrict\Stream; use Kiri\Router\Constrict\Stream;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
@@ -84,7 +85,7 @@ class Handler implements RequestHandlerInterface
return $this->typeEncode(); return $this->typeEncode();
} }
call_user_func($this->handler, ...$this->parameter); call_user_func($this->handler, ...$this->parameter);
return response(); return \response();
} }
@@ -102,7 +103,7 @@ class Handler implements RequestHandlerInterface
} else if (is_array($result)) { } else if (is_array($result)) {
$result = json_encode($result, JSON_UNESCAPED_UNICODE); $result = json_encode($result, JSON_UNESCAPED_UNICODE);
} }
return response()->withBody(new Stream($result)); return \response()->withBody(new Stream($result));
} }
} }