diff --git a/meta/definitions/http.php b/meta/definitions/http.php index 1ae4f7d..eb7fd0d 100644 --- a/meta/definitions/http.php +++ b/meta/definitions/http.php @@ -1,6 +1,6 @@ create(SapiEmitter::class), ThrowableHandlerInterface::class => autowire(ThrowableHandler::class), NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class), + # MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class), ]; diff --git a/src/ApplicationStrategy.php b/src/ApplicationStrategy.php index 7c55b3b..2897e70 100644 --- a/src/ApplicationStrategy.php +++ b/src/ApplicationStrategy.php @@ -2,8 +2,10 @@ namespace Lean; +use League\Route\Http\Exception\MethodNotAllowedException; use League\Route\Strategy; use League\Route\Http\Exception\NotFoundException; +use Lean\ApplicationStrategy\MethodNotAllowedInterface; use Lean\ApplicationStrategy\NotFoundDecoratorInterface; use Lean\ApplicationStrategy\ThrowableHandlerInterface; use Lean\Factory\HttpFactoryInterface; @@ -31,4 +33,9 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy { { return $this->getContainer()->get(ThrowableHandlerInterface::class); } + + public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface + { + return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); + } } \ No newline at end of file diff --git a/src/ApplicationStrategy/MethodNotAllowedInterface.php b/src/ApplicationStrategy/MethodNotAllowedInterface.php new file mode 100644 index 0000000..90b6653 --- /dev/null +++ b/src/ApplicationStrategy/MethodNotAllowedInterface.php @@ -0,0 +1,10 @@ +