-
Notifications
You must be signed in to change notification settings - Fork 1
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
Why isn't broker a handler? #10
Comments
It appears that there is in fact a separate handler implementation that does this, which is not apparent from the readme. Still, given that this handler implementation is not what the consumer of Broker will interact with, it seems more natural for Broker itself to be a handler. |
Broker can already be used as a handler, it just needs a |
If broker could be used as a handler, then I could use it in a method that accepts |
@XedinUnknown what would the benefit of that be? I tried implementing |
Sorry, perhaps I wasn't clear from the beginning. The consumers of Broker will most likely use it as an entry point to the application. They will probably marshal some environment values, such as those coming from a SAPI, into a server request object, give it to Broker, and emit the response. So, Broker is the main handler of the request, and therefore conceptually it looks more like a handler: they would want to "handle" the request in some familiar and interoperable way. Whereas if it is a middleware, they would have to have a stack implementation, and a handler, and a router/dispatcher. But Broker is already all that, so it looks more like a handler to me from this point too. I must admit that, although the concept of a middleware pipe in general (as opposed to HTTP specific middleware) was something that I had separately come up with a few years ago, I'm finding it hard to understand the separation between Middleware and Handler. Middleware is usually dispatched as part of a stack; each middleware can be capable of producing a response; and it should have the ability to "forward" the request to the next middleware somehow. So, not sure how the concept of "handler", especially as a second parameter to |
@XedinUnknown this is fixed in version 3.0.0, see #13. |
Upon reading the readme, I noticed that one way to dispatch the middleware pipe is with
Broker::handle()
. Given that a common use of handlers is as middleware dispatchers, shouldn'tBroker
implementRequestHandlerInterface
istead ofMiddlewareInterface
? This would look great to the consuming code, as the entry point would just need to do the same thing it would do if it were not using Broker:Given that Broker would probably be the top-most item of the stack that processes a request, it would make more sense for it to be a handler, rather than middleware, IMO.
The text was updated successfully, but these errors were encountered: