diff --git a/src/FallbackHandler.php b/src/FallbackHandler.php new file mode 100644 index 0000000..9769361 --- /dev/null +++ b/src/FallbackHandler.php @@ -0,0 +1,27 @@ +responseFactory = $responseFactory; + } + + public function handle(ServerRequestInterface $request): ResponseInterface + { + unset($request); // unused + + return $this->responseFactory->createResponse(503); + } +} diff --git a/src/FrameworkModule.php b/src/FrameworkModule.php index 7cb557c..884d2f1 100644 --- a/src/FrameworkModule.php +++ b/src/FrameworkModule.php @@ -24,9 +24,9 @@ class FrameworkModule extends AbstractModule * @param array $middlewares * @param AbstractModule|null $module */ - public function __construct(array $middlewares, AbstractModule $module = null) + public function __construct(array $middlewares = [], AbstractModule $module = null) { - $this->middlewares = $middlewares; + $this->middlewares = array_merge($middlewares, [FallbackHandler::class]); parent::__construct($module); } diff --git a/tests/FrameworkModuleTest.php b/tests/FrameworkModuleTest.php index 649a481..6c75dae 100644 --- a/tests/FrameworkModuleTest.php +++ b/tests/FrameworkModuleTest.php @@ -16,11 +16,7 @@ public function setUp(): void public function testCompile(): void { - $module = new FrameworkModule([ - FakeMiddleware::class, - FakeRequestHandler::class - ]); - + $module = new FrameworkModule(); $compiler = new DiCompiler($module, __DIR__ . '/../build/tests'); $instance = $compiler->getInstance(ApplicationInterface::class);