Hello.

IMHO, I think an empty interface is a bad thing, because the main aim of an 
interface is to define the api of an object (the public methods and their 
signatures). If it’s going to be two interfaces (for client and server 
middleware) I’d create two separate middleware stack and frame, because it 
makes no sense to typehint the middleware in some places and not in others.


> El 20 jun 2016, a las 18:20, Matthew Weier O'Phinney 
> <[email protected]> escribió:
> 
> On Mon, Jun 20, 2016 at 9:14 AM, Woody Gilk <[email protected] 
> <mailto:[email protected]>> wrote:
>> On Thu, Jun 16, 2016 at 3:24 PM, Matthew Weier O'Phinney
>> <[email protected]> wrote:
>>>> It definitely does not need to include the StackInterface. However, I
>>>> feel that it is valuable to provide a recommendation for it because of
>>>> the aforementioned concerns around being able to use client middleware
>>>> in a server stack.
>>> 
>>> I was stumbling on this, trying to figure out why client middleware 
>>> wouldn't be
>>> able to be used, as the ServerRequest fulfills the Request required by the
>>> client middleware ...  and then realized it's because of the separated
>>> interfaces bit (you wouldn't be able to compose the client middleware in 
>>> your
>>> stack if you typehint on ServerMiddleware).
>>> 
>>> As such, two pieces of feedback:
>>> 
>>> - Would this functionality be useful? Is anybody actually doing that today? 
>>> I
>>>  see some potential problems with it (e.g., what if the middleware
>>> creates a new
>>>  `RequestInterface` instance and passes it to `$frame->next()`?), and have 
>>> yet
>>>  to see a use case where I wouldn't just invoke that middleware directly 
>>> within
>>>  my server-side middleware.
>>> 
>>>  I'm willing to be convinced its useful, but I think we need to demonstrate 
>>> the
>>>  need in the meta document if it really is.
>>> 
>>> - Second, if it is useful, and thus we're keeping the MiddlewareInterface 
>>> as a
>>>  marker interface, we need more narrative around this in the meta document
>>>  detailing what I wrote above. Those reading the spec and meta document 
>>> should
>>>  not need to fill in the blanks and reason it out; the meta document should 
>>> do
>>>  that.
>> 
>> I think I agree with you but am struggling to find a reasonable way to
>> document this in the meta document without making it too heavy on
>> implementation details. Would you be willing to create a PR that fills
>> in that section? I've started to detail it in my latest changes to the
>> PR [1].
>> 
>> [1]: https://github.com/php-fig/fig-standards/pull/774
> 
> That's definitely a good start. Maybe add something like the following:
> 
>    `MiddlewareInterface` is provided as a common marker interface that may be
>    used in middleware stacks to allow middleware targeting either clients or
>    server-side requests. While `ServerRequestInterface` request instances may
>    always be passed to `ClientMiddlewareInterface`, as they extend from
>    `RequestInterface`, the opposite (passing a `RequestInterface` to a
>    `ServerMiddlewareInterface`) is not. `MiddlewareInterface` thus provides a
>    common base interface for each middleware type for server-side stacks that
>    wish to allow usage of client middleware (e.g., to proxy to another 
> server).
> 
>> Regarding this specifically:
>> 
>>> what if the middleware creates a new `RequestInterface` instance and passes 
>>> it to `$frame->next()`?
>> 
>> I have never seen a situation where the middleware would completely
>> replace the request. It should be assumed that the request can be
>> modified and passed, but not completely replaced. Do you think this
>> needs to be explicitly stated in the documentation?
> 
> The specific situation I can think of is that one might want to proxy to 
> another
> server (e.g., to serve a file from S3); in that case, you need to replace the
> URI to reference the proxied file at the very least, and may decide to create 
> a
> bare `RequestInterface` instance to delegate (to ensure it contains 
> appropriate
> headers, content, etc.).
> 
> That said, I'd likely just dispatch a client stack within my server-side
> middleware to do this, and return the response from it.
> 
> My thought is that in `ServerMiddlewareInterface::process()`'s docblock, we 
> may
> want to indicate that implementations should always pass a
> `ServerRequestInterface` to `$frame->next()`, and never a non-server variant, 
> to
> ensure proper execution fo the frame.
> 
> -- 
> Matthew Weier O'Phinney
> [email protected] <mailto:[email protected]>
> https://mwop.net/ <https://mwop.net/>
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "PHP Framework Interoperability Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/php-fig/CAJp_myWZvjAsUvMm9aw7iM8nC14Y7jOaZ72s1fzsSkFKqzUmcA%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/php-fig/CAJp_myWZvjAsUvMm9aw7iM8nC14Y7jOaZ72s1fzsSkFKqzUmcA%40mail.gmail.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/8AE7C0B5-F29A-4B80-8F4A-4A8163B9D46C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to