Replies: 4 comments 2 replies
-
Hi there @ilhooq, Thank you for your idea to implement interfaces in Handlers, it sounds like an interesting idea. I would like to learn more about what you think an improvement like this would achieve. Can you please describe your use-case in a bit more detail? If this was implemented, how would this improve your application and your use of this library? Thank you, James |
Beta Was this translation helpful? Give feedback.
-
Hi James, First of all, I just want to say that, in the actual state, the library works fine. Thank you for your effort. What I explained above is just a suggestion for an enhancement. The goal of the use case I described (a common error handler) is to avoid to check errors for each handler separately. In the actual state, it's possible to achieve this goal but without to be sure that the handler implement the method Now, with the use of a common interface, it would guaranty that each handler implements the Another use case could be to create a custom handler factory. If each handler implements a function createHandler(string $name): OpenaiHandlerInterface
{
//...
}
$handler = createHandler('edits');
// Now, we are sure that $handler have the create method
$handler->create($request); I Hope this will be helpful. Regards |
Beta Was this translation helpful? Give feedback.
-
Hi @ilhooq , Can you tell me more about the use case of interfaces from a library consumer perspective? I am especially interested in the If you have any other ideas, please tell us too. I appreciate your time and effort. |
Beta Was this translation helpful? Give feedback.
-
Hi @ilhooq Thank you for the detailed explanation. It certainly makes sense now. Even though our roadmap is not public, I am adding this as a feature request. |
Beta Was this translation helpful? Give feedback.
-
For some reasons, it would be great if all api Handlers implement an interface.
One reason could be to use a common function/method to handle errors, for instance:
As base interface I suggest to use PSR-15 Psr\Http\Server\RequestHandlerInterface.
The final interface could be:
Beta Was this translation helpful? Give feedback.
All reactions