http-interop / http-middleware

PSR-15 interfaces for HTTP Middleware
MIT License
73 stars 7 forks source link

Delegate interface and dispatcher wording in README.md #54

Closed schnittstabil closed 7 years ago

schnittstabil commented 7 years ago

Form the current README.md

5.2 Delegate Design

The DelegateInterface defines a single method that accepts a request and returns a response. The delegate interface must be implemented by any middleware dispatcher that uses middleware implementing ServerMiddlewareInterface.

The bold marked part is technically wrong, Equip\Dispatch\MiddlewarePipe is a counter example. Obviously, it is a middleware dispatcher which should not implement the DelegateInterface; instead it creates a DelegateInterface instance:

class MiddlewarePipe implements ServerMiddlewareInterface
{
    …
    /**
     * Dispatch the middleware stack.
     *
     * @param ServerRequestInterface $request
     * @param callable $default to call when no middleware is available
     *
     * @return ResponseInterface
     */
    public function dispatch(ServerRequestInterface $request, callable $default)
    {
        $delegate = new Delegate($this->middleware, $default);

        return $delegate->process($request);
    }
}
atanvarno69 commented 7 years ago

Would this wording be more correct?

The delegate interface must be implemented by any middleware dispatching library or package that uses middleware implementing ServerMiddlewareInterface.

This describes that DelegateInterface must be provided to dispatched middleware without implying that a pipe implementation like Equip\Dispatch need implement it directly.

schnittstabil commented 7 years ago

@atanvarno69 Well, I believe such a list will never be comprehensive.

Maybe we should just remove the sentence without replacement. Because of the MiddlewareInterface::process signature and the 5.1 Middleware Design paragraph it is already clear that:

shadowhand commented 7 years ago

You are free to make your case during the PSR-15 review period. I am calling for the PSR-15 acceptance vote before Jan 17.