diff --git a/meta/definitions/authorize.php b/meta/definitions/authorize.php index 571fa24..6d79ba0 100644 --- a/meta/definitions/authorize.php +++ b/meta/definitions/authorize.php @@ -3,19 +3,15 @@ use Lean\Factory\HttpFactoryInterface; use Ulmus\User\{ - Authorize\HeaderAuthentication, + Authorize\HeaderAuthentication, Authorize\PostRequestAuthentication, Entity, - Lib\Authenticate, - Lib\Authorize, - Middleware\AuthenticationMiddleware, - Middleware\HeaderAuthenticationMiddleware, - Middleware\PostRequestAuthenticationMiddleware, - Authorize\PostRequestAuthentication + Lib\Authenticate, Lib\Authorize, + Middleware\AuthenticationMiddleware, Middleware\HeaderAuthenticationMiddleware, Middleware\PostRequestAuthenticationMiddleware, }; +use Picea\Picea; use Storage\{ Cookie, Session }; use Psr\Container\ContainerInterface; -use Picea\Picea; use function DI\{get, autowire, create}; @@ -39,7 +35,6 @@ return [ 'authorize.error' => function(ContainerInterface $c) { return function(array $errorData) use ($c) { return $c->get(HttpFactoryInterface::class)::createJsonResponse($errorData + [ - 'api.error' => "Authorization failed", 'api.datetime' => (new \DateTime)->format(\DateTime::ATOM), ], 403); diff --git a/meta/definitions/http.php b/meta/definitions/http.php index 56fd0ff..e82c32e 100644 --- a/meta/definitions/http.php +++ b/meta/definitions/http.php @@ -3,6 +3,7 @@ use Psr\Container\ContainerInterface; use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, }; + use Psr\Http\Message\ServerRequestInterface; use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter }; use Lean\Factory\{ HttpFactory, HttpFactoryInterface }; diff --git a/src/ApplicationStrategy/NotFoundDecorator.php b/src/ApplicationStrategy/NotFoundDecorator.php index 8ce628f..d4ac54d 100644 --- a/src/ApplicationStrategy/NotFoundDecorator.php +++ b/src/ApplicationStrategy/NotFoundDecorator.php @@ -39,7 +39,7 @@ class NotFoundDecorator implements NotFoundDecoratorInterface public function throw404(ServerRequestInterface $request) : ResponseInterface { - return $this->checkAssetTrigger($request) ?: $this->httpFactory->createHtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404); + return $this->checkAssetTrigger($request) ?: $this->container->get('error.404'); } protected function checkAssetTrigger(ServerRequestInterface $request) : false|ResponseInterface diff --git a/src/Factory/HttpFactoryInterface.php b/src/Factory/HttpFactoryInterface.php index 6fedd29..e721bdd 100644 --- a/src/Factory/HttpFactoryInterface.php +++ b/src/Factory/HttpFactoryInterface.php @@ -17,6 +17,5 @@ interface HttpFactoryInterface public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface; public static function createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface; public static function createFileDownloadResponse(string $path, int $code = 200, array $headers = []) : ResponseInterface; - public static function createStream(string $content) : StreamInterface; }