assertValidRegistrationRequest is a public (non-static) method with a valid middleware signature:
public function assertValidRegistrationRequest(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
This however results in a
Uncaught RuntimeException: A middleware must be an object/class name referencing an implementation of MiddlewareInterface or a callable with a matching signature. in /app/vendor/slim/slim/Slim/MiddlewareDispatcher.php:92
where $callableResolver is of type DI\Bridge\Slim\CallableResolver. This however feels very verbose.
// or
$app->get('/register-platform', [RegisterPlatform::class, 'getRegister'])
->add(RegisterPlatform::class . '::assertValidRegistrationRequest');
but this is ugly.
Is it too extreme to override the MiddlewareDispatcher here to allow these notations? Otherwise the problem needs to be fixed in Slim's MiddlewareDispatcher to defer all middleware notations to the CallableResolver instead of only string variants.
Just a stub for now, I'll try to expand this later.
Bit related: https://github.com/slimphp/Slim/issues/2780
I was trying to do this:
assertValidRegistrationRequest
is a public (non-static) method with a valid middleware signature:This however results in a
My current workaround/solution is:
where
$callableResolver
is of typeDI\Bridge\Slim\CallableResolver
. This however feels very verbose.but this is ugly.
Is it too extreme to override the
MiddlewareDispatcher
here to allow these notations? Otherwise the problem needs to be fixed in Slim's MiddlewareDispatcher to defer all middleware notations to the CallableResolver instead of onlystring
variants.