Ok, despite some prototype related issues, I do not understand how you want 
to stack multiple RequestMiddlewareInterface instances?

For example one which adds the computation time, but only if the next 
middleware (e.g. the AuthHeaderMiddleware) returned with status === 200.



On Tuesday, February 21, 2017 at 8:09:36 PM UTC+1, John Porter wrote:
>
> Woody,
>
> Here's an example meeting your criteria (I think):
>
> <?php
>
> namespace Example;
>
> use Psr\Http\Message\MessageInterface;
> use Psr\Http\Message\RequestInterface;
> use Psr\Http\Middleware\RequestMiddlewareInterface;
> use Psr\Http\Middleware\ResponseFactoryInterface;
>
> class AuthHeaderMiddleware implements RequestMiddlewareInterface, 
> ResponseFactoryInterface
> {
>     public function parseRequest(RequestInterface $request): 
> MessageInterface
>     {
>         if ($request->getMethod() === 'POST' && $request->hasHeader(
> 'authorization')) {
>             return $request; // Passthrough here
>         }
>
>         $response = $this->createResponseInstance();
>
>         return $response->withStatus(401); // short circuit handled by 
> middleware runner implementing ExchangeInterface
>     }
> }
>  
>

-- 
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 php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/227f5190-8449-4546-a5c0-1d88f4340edc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to