- Fixed a bug where Assets would not load properly

This commit is contained in:
Dave Mc Nicoll committed 2025-05-26 18:20:22 +00:00
1 parent d181c6d3a7
commit 2dbcfbcb2e
5 files changed
+65 -54

No files matched your search

@@ -0,0 +1,33 @@
<?php
namespace Lean\Api\ApplicationStrategy;
use DI\Attribute\Inject;
use Lean\Factory\HttpFactoryInterface;
use Picea\Picea;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
class NotFoundDecorator extends \Lean\ApplicationStrategy\NotFoundDecorator
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (php_sapi_name() !== 'cli' and ! defined('STDIN')) {
return $this->throw404($request);
}
return parent::process($request, $handler);
}
public function throw404(ServerRequestInterface $request) : ResponseInterface
{
return $this->checkAssetTrigger($request) ?: $this->httpFactory->createJsonResponse([
'status' => 'error',
'message' => "Not Found",
'ts' => time(),
], 404);
}
}