summaryrefslogtreecommitdiff
path: root/src/BasicStrategy.php
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
committerSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
commit8abfce2091e9665af93a920aed246e3b04abc2aa (patch)
treebd72ace84cdb6716170bb71fc7d7fbb45c5fb33d /src/BasicStrategy.php
parentc540b7ac4dedb94cffe9aaeae9f936aba2a36d79 (diff)
throw an exception when route handler does not return response
Diffstat (limited to 'src/BasicStrategy.php')
-rw-r--r--src/BasicStrategy.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/BasicStrategy.php b/src/BasicStrategy.php
index 62bc48e..5043576 100644
--- a/src/BasicStrategy.php
+++ b/src/BasicStrategy.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Lightscale\Router;
use Lightscale\Router\Contracts\Strategy;
+use Lightscale\Router\Exceptions\InvalidResponseException;
use Lightscale\Router\Exceptions\NotFoundException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
@@ -13,7 +14,13 @@ class BasicStrategy implements Strategy
{
public function runRoute(RouteCall $call): ResponseInterface
{
- return ($call->route->getHandler())($call);
+ $result = ($call->route->getHandler())($call);
+
+ if ($result instanceof ResponseInterface) {
+ return $result;
+ }
+
+ throw new InvalidResponseException();
}
public function notFound(RequestInterface $request): ResponseInterface