Could you be a little more clear for me? Can you explain what you mean by prototype related issues?
Also, to aid me in showing accurate examples: Where would the computation time be added, to a request or response? Can you show me how you’d achieve it with the double pass method, and I can show you the alternative. I think I understand what you mean, but I want to be sure. Plus it’s late, I’m tired and I’ve had a beer :) On 21 February 2017 at 19:43:24, Michael Mayer ([email protected]) wrote: 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 a topic in the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/vCKxyraoqnc/unsubscribe. To unsubscribe from this group and all its topics, 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/227f5190-8449-4546-a5c0-1d88f4340edc%40googlegroups.com. For more options, visit 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/etPan.58ac99e9.7fe023c.2227%40designermonkey.co.uk. For more options, visit https://groups.google.com/d/optout.
