Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Treat Route $handler that implements RequestHandlerInterface as callable #324

Open
bertramakers opened this issue Aug 22, 2022 · 0 comments

Comments

@bertramakers
Copy link

bertramakers commented Aug 22, 2022

We have an implementation of RequestHandlerInterface for every route in our app. We currently have to register them on the router like this (simplified for example):

$helloRequestHandler = new HelloRequestHandler(); // implements RequestHandlerInterface

$router = new Router();
$router->get('/hello', [$helloRequestHandler, 'handle']);

Since RequestHandlerInterface is an interface from PSR-15, and this package supports PSR-15 (middlewares), it would be cool if the router could automatically detect the 'handle' method on the request handlers, so we could just register them like:

$helloRequestHandler = new HelloRequestHandler(); // implements RequestHandlerInterface

$router = new Router();
$router->get('/hello', $helloRequestHandler);

(Or when injecting a dependency container into the router, as a FQN / service name without the ::handle)

Is this something that you would consider approving if I created a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant