-
Notifications
You must be signed in to change notification settings - Fork 5
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
Every handler needs to inject the config even if is not needed #313
Comments
what if we ask @Xerkus to give his opinion in this matter ? |
config in the handler is messed up. Deprecate and get rid of it. Those handler traits are problematic from code quality perspective. It would be good to get rid of them as well. Move them into injectable dependencies. I am cloning the repo and will take a closer look. |
Config in handle has only one purpose: to find out if a GET request is for a single item or a collection of items.
Why are they problematic? They are just as easy to test as a handler.
I'm curious to see your findings. :) |
Handler being aware of config structure, of metadata map and its structure is a sever violation of single responsibility principle. Extract the Better yet, I would recommend to abandon the approach of handling the resource and its collection in the same handler. I personally prefer to separate get and post/patch/delete actions further into separate handlers. It makes middleware pipes so much more powerful with a simple composition. For the response trait I would also recommend to extract it into an object in its entirety and inject it as a dependency. It can be improved by utilizing PSR-17 factories and further improved by the use of |
Signed-off-by: alexmerlin <[email protected]>
Issue #313: Remove `config` dependency from handlers.
We elliminated the |
Every new handler needs to inject the config in order to work, even if you create a simple handler for outputing a simple get response.
This is because the method
isGetCollectionRequest
from HandlerTrait request it.I think this is related to #269
The text was updated successfully, but these errors were encountered: